[Android] How to make round box
Sometimes when you create a button, you want to create a list or a specific box to display the information inside.
In the case of round boxes through images, it is the neatest to apply mainly through xml design because it has the disadvantage of being fixed size or breaking image. (From what I know...)
It's very simple to use, but it's a waste of memory to use, so it's best to leave it and copy it
How to make round box
Create one border.xml in the res > drawable folder and copy the source below.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<stroke
android:width="1dp"
android:color="#9e8181"/>
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp"/>
<corners
android:bottomLeftRadius="7dp"
android:bottomRightRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp"/>
</shape>
Apply the created border image as the background of the Relative Layout.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/border"
android:layout_margin="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Examples of text box utilization."
</RelativeLayout>
Description
Android:shape can be created in four forms: [rectangle/oval/line/ring]
- rectangle: square
- oval: circle
- line: linear
- ring: cylindrical
<solid>
: In rectangle, solid can only be applied to the interior color of the rectangle (android:color).
- color:inner color of rectangle
<stroke>
: In rectangle, stroke is the setting for the square border.
- width: thickness of border line
- color:color of border line
- dashGap: If you want to apply the border as a dotted line rather than a solid, the interval between the points
- dashWide: the length of the point if you want to apply the border as a dotted line rather than a solid line
<padding>
: A space inside a square that means the spacing between letters and borders when used in buttons.
<cornors>
: It can be applied if you make a button with rounded corners. Depending on the size, it can even be circular.
<gradient>
: This is possible if the gradient is applied inside the button.
[Android] How to make Round Box
🇰🇷 Korean
2020.07.23 - [개발 창고/Android] - [Android] round box 만들기