效果如下:
代码:
text_diver.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="12dp" android:layout_marginRight="12dp" android:divider="@drawable/space" android:orientation="horizontal" android:padding="2dp" android:showDividers="middle"> <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.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#00000000"/> <size android:width="5dp" android:height="1dp"/> </shape>
TestDivider
package com.example.myapp; import android.app.Activity; import android.os.Bundle; public class TestDivider extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.text_diver); } }