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 만들기
[Android] round box 만들기
가끔 버튼을 만들다 보면 리스트나 특정 박스를 만들어 내부에 정보를 표기하고 싶은 경우가 생기곤 합니다. 이미지를 통한 라운드 박스의 경우 고정 크기 아니면 이미지가 깨지는 단점이 있기
royzero.tistory.com
'개발 창고 > Android' 카테고리의 다른 글
[Android] How to use multiple shapes (36) | 2024.02.19 |
---|---|
[Android] 폰트(font) 적용하기 (7) | 2024.02.13 |
[Android] ActionBar 타이틀 변경과 뒤로가기 추가 - Kotlin (167) | 2024.02.07 |
[Android] How to use SharedPreference (143) | 2024.02.06 |
[Android] 안드로이드 버전 확인 하는 방법 (188) | 2024.01.04 |