Divider and Space

Example to use divider and space
Create our divider in drawable folder:

drawable/myhdivider.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:height="1dp" />
<solid android:color="#A00000FF" />
</shape>

drawable/myvdivider.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:width="1dp"/>
<solid android:color="#A0FF0000" />
</shape>

Edit layout to use our dividers in LinearLayout, and also insert space.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
android:orientation="vertical"
android:divider="@drawable/myhdivider"
android:showDividers="middle"
tools:context=".MainActivity"
android:background="#D0D0D0">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android-er"
android:textStyle="bold" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:divider="@drawable/myvdivider"
android:dividerPadding="5dp"
android:showDividers="middle"
android:background="#B0B0B0">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="button"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="button"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="button"/>
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="50dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="button"
android:background="?android:attr/selectableItemBackground"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="button"
android:background="?android:attr/selectableItemBackground"/>


</LinearLayout>

Divider and Space Divider and Space Reviewed by Pendik on 18.12 Rating: 5

Tidak ada komentar:

Diberdayakan oleh Blogger.