巧用TextView实现分隔线

来源:互联网 发布:mysql for mac 下载 编辑:程序博客网 时间:2024/05/01 05:56

在写这个项目的时候,需要用到分隔线,思索无果,后来想到TextView恍然大悟,一点小技巧。在在


先上效果图:


布局代码:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/container"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    tools:context="com.example.theold.MainActivity"    tools:ignore="MergeRootFrame" >      <LinearLayout         android:id="@+id/linearlayoutmain"        android:orientation="vertical"        android:layout_width="fill_parent"        android:layout_height="wrap_content">                                       <DigitalClock             android:layout_weight="1"            android:id="@+id/clock"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:textSize="70sp"            android:layout_gravity="center_horizontal"            android:background="@drawable/time_bg"            android:textColor="#000000"/>                <TextView             android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:textSize="30sp"            android:fontFamily="宋体"            android:background="#ADFF2F"            android:id="@+id/dateandweather"/>                       <LinearLayout            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">        <ImageButton             android:layout_weight="1"            android:src="@drawable/img_call"            android:id="@+id/enterPhoneCall"            android:background="@drawable/selector"            android:layout_width="fill_parent"            android:layout_height="wrap_content"/>                <TextView             android:background="#000000"            android:layout_width="4dp"            android:layout_height="fill_parent"/>                <ImageButton             android:layout_weight="1"            android:src="@drawable/img_message"            android:id="@+id/enterMessage"           android:background="@drawable/selector"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            />        </LinearLayout>                <TextView             android:background="#000000"            android:layout_width="fill_parent"            android:layout_height="4dp"/>                                 <LinearLayout            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">        <ImageButton             android:layout_weight="1"            android:id="@+id/enterFlashlight"            android:src="@drawable/img_flashlight"            android:background="@drawable/selector"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            />                <TextView             android:background="#000000"            android:layout_width="4dp"            android:layout_height="fill_parent"/>                <ImageButton             android:layout_weight="1"            android:id="@+id/enterMusic"           android:background="@drawable/selector"           android:src="@drawable/img_music"            android:layout_width="fill_parent"            android:layout_height="wrap_content" />        </LinearLayout>                       <TextView             android:background="#000000"            android:layout_width="fill_parent"            android:layout_height="4dp"/>                                 <LinearLayout            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">        <ImageButton             android:layout_weight="1"            android:id="@+id/enterCamera"            android:src="@drawable/img_camera"            android:background="@drawable/selector"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            />                <TextView             android:layout_width="4dp"            android:background="#000000"            android:layout_height="fill_parent"/>                <ImageButton             android:layout_weight="1"            android:id="@+id/enterPhotos"            android:src="@drawable/img_photo"           android:background="@drawable/selector"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            />                        </LinearLayout>                                <TextView             android:background="#000000"            android:layout_width="fill_parent"            android:layout_height="4dp"/>                                 <LinearLayout            android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">        <ImageButton             android:layout_weight="1"            android:id="@+id/enterSOS"           android:background="@drawable/selector"            android:src="@drawable/img_sos"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            />                <TextView             android:layout_width="4dp"            android:background="#000000"            android:layout_height="fill_parent"/>                <ImageButton             android:layout_weight="1"            android:src="@drawable/img_compass"            android:id="@+id/enterCompass"           android:background="@drawable/selector"            android:layout_width="fill_parent"            android:layout_height="wrap_content"            />        </LinearLayout>                    <TextView             android:background="#000000"            android:layout_width="fill_parent"            android:layout_height="4dp"/>        <LinearLayout             android:layout_width="fill_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">        <ImageButton             android:id="@+id/enterAboutMore"            android:layout_width="fill_parent"            android:background="#2E8B57"            android:src="@drawable/img_aboutmore"            android:layout_height="wrap_content"/>        </LinearLayout>            </LinearLayout></ScrollView>



1 0
原创粉丝点击