如何创建一个View的分割线,如上图
我们见介绍三种可以创建看起来很不错的view的分割线,如在button之间添加分割线。
这个例子是将为LinearLayout内的三个Button间添加分割线。
这三个例子可能容易实现,相信会有更好的实现办法。
1 人工添加LinearLayout的分割线
我们可以创建一个View,这个View就是分割线,只要简单在Button之间添加这个分割线就可以。
分割线的实现,如下:
<View
android:layout_height="fill_parent"
android:layout_width="1dp"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
/>
So the whole layout, as pictured, becomes:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:orientation="horizontal">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Yes"
android:layout_weight="1"
android:id="@+id/button1"
android:textColor="#00b0e4" />
<View android:layout_height="fill_parent"
android:layout_width="1px"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:id="@+id/separator1" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="No"
android:layout_weight="1"
android:id="@+id/button2"
android:textColor="#00b0e4" />
<View android:layout_height="fill_parent"
android:layout_width="1px"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:id="@+id/separator2" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/buttonBarButtonStyle"
android:text="Neutral"
android:layout_weight="1"
android:id="@+id/button3"
android:textColor="#00b0e4" />
</LinearLayout>