LinkearLayout์ divider ์ฝ์
5328 ๋จ์ด Android
์ง๊ธ๊น์ง
API Level 11์์ LineearLayout๊น์งdivider๋ฅผ ์ฝ์ ํ ์๋ ์์ต๋๋ค.
์ฌ์ฉ๋ฒ
ListView์์๋ ํ์ค์ผ๋ก ์ฌ์ฉ๋์ง๋ง, LiearLayout์์๋ ๋ชจ๋ ํญ๋ชฉ ๊ฐ์ ๊ณตํต๋ ๊ตฌ๋ถ์ ์ ๊ทธ๋ ค๋ณด๋ ค๋ ๊ฒฝ์ฐ๋ ํญ๋ชฉ ๊ฐ ๊ฑฐ๋ฆฌ๋ฅผ ์ฝ๊ฒ ์ค์ ํ๋ ค๋ ๊ฒฝ์ฐ์๋ ์ฌ์ฉํ ์ ์๋ค.
ํ์์ ์ง์ ํ ๋๋ ๋ค์๊ณผ ๊ฐ๋ค.
layout.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@layout/divider"
android:dividerPadding="20dp"
android:showDividers="middle"
android:orientation="vertical" >
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="xxxx"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="xxxx"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="xxxx"
/>
</LinearLayout>
ํ์ํ ์์ฑ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.๋ฑ๋ก ์ ๋ณด
์ํฅ
๊ฐ
divider
Divider
drawble ์ฐธ์กฐ
dividerPadding
Divider ์์ชฝ ๋์ ์๋ Padding
์ฐธ์กฐ ๋ฒํธ ๋๋ dimens
showDividers
Divider ๋์คํ๋ ์ด ์ค์
๊ธฐ๋ณธ๊ฐ, middle, beginning, end
showDividers ๊ฐ์ OR์ ์ง์ ํ ์ ์์ต๋๋ค.
์ ๋ ์ด์์์ ๋ค์ divider๊ฐ ์ค๋น๋์ด ์์ผ๋ฉด ๋ค์ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด ํ์๋ฉ๋๋ค.
ยท ๋ ์ด์์ ๋ฐ์ ๋๊ธฐ
divider.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/divider_item"
android:top="5dp"
android:bottom="5dp" />
</layer-list>
drawable ์๋์ ๋๊ธฐdivider_item.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<size android:height="1dp" />
<solid android:color="@android:color/black" />
</shape>

divider์ ์์ ํฌ๋ช ํ๊ฒ ํ์ฌ ์ฌ๋ถ์ผ๋ก ์ฌ์ฉํ ์๋ ์์ต๋๋ค.
divider_item.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<size android:height="1dp" />
<solid android:color="@android:color/transparent" />
</shape>

์ฃผ์์
divider์ ๋ํด ์ด๋ฏธ์ง ์์์ ์ค์ ํ ์ ์์ต๋๋ค
divider="@android :color/black"
์ด๋ฌํ ์์์ ์ง์ ํ ์ ์์ต๋๋ค.
์์ ์ฐธ์กฐ๋ฅผ ๊ต๋ถํ๋๋ผ๋ Drawable์ด ์์ฑ๋์ง๋ง ๋์ด๋ 0์ ๋๋ค.
ListView์ ๋ฌ๋ฆฌ divider Height๋ฅผ ์ค์ ํ ์ ์๊ธฐ ๋๋ฌธ์ ๊ณ ๋์ Drawable๋ฅผ ๊ต๋ถํด์ผ ํฉ๋๋ค.
Reference
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(LinkearLayout์ divider ์ฝ์ ), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค https://qiita.com/kubotaku1119/items/31c61c07e916fe2f8e48ํ ์คํธ๋ฅผ ์์ ๋กญ๊ฒ ๊ณต์ ํ๊ฑฐ๋ ๋ณต์ฌํ ์ ์์ต๋๋ค.ํ์ง๋ง ์ด ๋ฌธ์์ URL์ ์ฐธ์กฐ URL๋ก ๋จ๊ฒจ ๋์ญ์์ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ
์ธ ๋ฐ๊ฒฌ์ ์ ๋
(Collection and Share based on the CC Protocol.)
์ข์ ์นํ์ด์ง ์ฆ๊ฒจ์ฐพ๊ธฐ
๊ฐ๋ฐ์ ์ฐ์ ์ฌ์ดํธ ์์ง
๊ฐ๋ฐ์๊ฐ ์์์ผ ํ ํ์ ์ฌ์ดํธ 100์ ์ถ์ฒ ์ฐ๋ฆฌ๋ ๋น์ ์ ์ํด 100๊ฐ์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ๋ฐ์ ํ์ต ์ฌ์ดํธ๋ฅผ ์ ๋ฆฌํ์ต๋๋ค