色彩时光 | 记录程序员世界的点点滴滴

android 布局整理


在布局元件中加入分隔线方法:


android:divider="@drawable/shape_spacer_medium"
android:background="#cccccc"
android:showDividers="middle"

<!--shape_spacer_medium-->
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android= "http://schemas.android.com/apk/res/android"   
    android:shape= "rectangle"
     android:insetTop="8dp"
     android:insetBottom="8dp">  
     <shape>
	    <size  
	        android:width= "1dp"   
	        android:height= "5dp"  />
	    <solid android:color= "#999999"  />  
    </shape>
</inset>  

元件底部边框绘制:


<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
	<item android:right="1dp" android:left="1dp">
	    <shape android:shape="rectangle" >
	        <solid android:color="#ff0000" />
	    </shape>
	</item>
	<item android:right="1dp" android:left="1dp" android:bottom="1dp">
	    <shape android:shape="rectangle" >
	        <solid android:color="#cccccc" />
    	</shape>
	</item>  
</layer-list> 

在去除背景使用setBackgroundResource(0)莫名会有边框,而setBackgroundColor(0x00000000)则不会产生边框。


您可能也对下面文章感兴趣:

Write a Comment


* Content (required) 10~500s

分类

热门标签

友情链接