반응형
라운드 사각 백그라운드를 xml로 만드는 예제입니다.
아래는 TextView에 외곽배경을 준 것입니다.
xml파일 입니다.
drawable 폴더밑에 roundrect_background.xml 로 저장했습니다.
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!--<solid android:color="#FFFFFF"/>-->
<stroke
android:width="1dp"
android:color="#ffffff"/>
<padding
android:bottom="2dp"
android:left="3dp"
android:right="3dp"
android:top="2dp"/>
<corners
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"/>
</shape>
색상, 패딩, 코너값을 원하는 데로 수정하면 되구요.
주석처리된 solid를 사용하면 사각영역 안을 해당 색상으로 채우게 됩니다.
사용하는 TextView xml 입니다.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11dp"
android:textColor="#ffffff"
android:text="MODE"
android:background="@drawable/roundrect_background"/>
요런 간단한 건 이미지로 만드는 것 보단 xml이 더 편한것 같네요.
반응형
'안드로이드' 카테고리의 다른 글
Android Version List (1) | 2021.11.14 |
---|---|
Android RecyclerView StaggeredGrid (0) | 2021.11.14 |
Android RecyclerView (0) | 2021.11.14 |
TextView Center Line(취소선, 텍스트 중간에 줄긋기 옵션) (0) | 2017.11.24 |
Android EditText 변경 이벤트 받기(ListView, RecyclerView 안에서도 받기) (0) | 2017.11.23 |
최근댓글