본문 바로가기

Study/Android

[android] 선, 둥근 백그라운드 그리기

선 그리기

drawable/shape_line.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="line">
    <stroke android:width="3dip" android:color="@color/dark_gray" />
</shape>

 

layout/main.xml

<View android:id="@+id/line"
        android:layout_width="wrap_content" android:layout_height="10dip"
        android:background="@drawable/shape_line" 
        />

 

 

둥근 백그라운드 그리기

drawable/shape_white_back.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="@color/white" />
    <padding android:left="5dip" android:top="5dip"
        android:right="5dip" android:bottom="5dip"
        />
    <corners android:radius="4dip" />
</shape>

 

layout/main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="@drawable/shape_white_back"
    android:orientation="vertical"
    android:layout_margin="30dip"
    android:padding="5dip"
    />

 

solid : 색을 채워 넣는다.

padding : 안쪽으로 여백을 준다.

corners : 모서리를 둥글게 한다.

stroke : 테두리를 준다.