android 布局一种好看的高亮布局

来源:互联网 发布:数据库接口类型有哪些 编辑:程序博客网 时间:2024/05/01 19:51

高亮设定

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bg_color">
    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:orientation="vertical" >
     <RelativeLayout            
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_more_button"
            android:clickable="true"
            android:padding="10dp" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"              
                android:text="@string/luyin"
                android:textColor="@color/text_color"
                android:textSize="@dimen/textsize16" />


            <Switch
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/can_record"
                android:textOff="@string/luyinclose"  
                android:textOn="@string/luyinstart"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                 />
        </RelativeLayout>
     <RelativeLayout          
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_more_button"
            android:layout_marginTop="10dp"
            android:clickable="true"
            android:padding="10dp" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"              
                android:text="@string/luyinshangchuan"
                android:textColor="@color/text_color"
                android:textSize="@dimen/textsize16" />
            <Switch
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/up_record"
                android:textOff="@string/luyinclose"  
                android:textOn="@string/luyinstart"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                 />
        </RelativeLayout> 
    
        <RelativeLayout          
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_more_button"
            android:layout_marginTop="10dp"
            android:clickable="true"
            android:padding="10dp" >
            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="4dp" 
                android:hint="192.168.0.181"  
                android:id="@+id/ipPort"                           
                android:textColor="@color/text_color"
                android:textSize="@dimen/textsize16" />
            <Switch
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/ipSure"
                 android:textOff="@string/ipport1"  
                android:textOn="@string/ipport2"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                 />
        </RelativeLayout> 
            <RelativeLayout          
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_more_button"
            android:layout_marginTop="10dp"
            android:clickable="true"
            android:padding="10dp" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"              
                android:text="@string/saveposition"
                android:id="@+id/stragePos"                
                android:textColor="@color/text_color"
                android:textSize="@dimen/textsize16" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_toRightOf="@+id/stragePos"
                android:layout_marginLeft="4dp"                              
                android:id="@+id/recordPath"
                android:textColor="@color/text_color"
                android:textSize="@dimen/textsize16" />
            <Switch
                android:layout_width="2dp"
                android:layout_height="2dp"
                android:id="@+id/sdcardOption"
                android:textOff="@string/storage1"  
                android:textOn="@string/storage2"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                 />
        </RelativeLayout> 
 </LinearLayout>
</ScrollView>

//  对应的背景  android:background="@drawable/bg_more_button"

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">


    <item android:state_pressed="true"><shape>
            <gradient android:angle="270" android:endColor="#cfcfcf" android:startColor="#cfcfcf" />


            <stroke android:width="1dp" android:color="#cfcfcf" />


            <corners android:bottomLeftRadius="0dp" android:bottomRightRadius="0dp" />
        </shape></item>
    <item android:state_focused="true"><shape>
            <gradient android:angle="270" android:endColor="#cfcfcf" android:startColor="#cfcfcf" />


            <stroke android:width="1dp" android:color="#cfcfcf" />


            <corners android:bottomLeftRadius="0dp" android:bottomRightRadius="0dp" />
        </shape></item>
    <item><shape>
            <gradient android:angle="270" android:endColor="#ffffff" android:startColor="#ffffff" />


            <stroke android:width="1dp" android:color="#d0d0d0" />


            <corners android:bottomLeftRadius="0dp" android:bottomRightRadius="0dp" />
s        </shape></item>


</selector>
1 0