IT이야기/Android

안드로이드 실선 그리기

FelixShin 2016. 10. 14. 15:48
반응형



View 객체를 이용해서 xml에 아래와 같이 넣어주면 된다.


1. 실선그리기

<View
android:layout_width="150dp"
android:layout_height="1dp"
android:background="@color/menu_character_color"
android:layout_gravity="center"/>


- background는 color를 이용해 미리 정의한 색을 가져온 것으로 values - color.xml에 아래와 같이 정의되어서 사용 가능

 # 직접 hex color code 입력을 통해서도 색상 입력이 가능

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="menu_character_color">#C8C9CA</color>
</resources>

-  layout_gravity는 해당 layout내에서 정렬을 말함


2. 수직선 그리기 (xml 내에서 그림)

<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@color/menu_character_color"
android:layout_gravity="center"/>


3. 수평선 그리기 (xml 내에서 그림)

<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="@color/menu_character_color"
android:layout_gravity="center"/>