Android 安卓形线条
我有以下代码:Android 安卓形线条,android,shape,Android,Shape,我有以下代码: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp"/> <size android:height="1dp" /> <solid android:color="#FFF"/> </shape> &
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke android:width="1dp"/>
<size android:height="1dp" />
<solid android:color="#FFF"/>
</shape>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background ="@drawable/line"/>
我有两个问题:
上定义。该元素用于背景
2) 可以使用,aka#ARGB设置形状的不透明度。在您的例子中,可能是#7FFF.最简单的2密度黑色像素线示例。 只需将xml保存在drawable文件夹中:res/drawable/shape\u black\u line.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#000000" />
<size android:height="2dp" />
</shape>
使用LinearLayout和background显示线条
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/divider">
</LinearLayout>
我希望这能有所帮助。一个棘手的方法是: 1) 在需要线条的位置添加视图 2) 将android:background设置为一个十六进制值,您可以同时设置颜色和不透明度 例如:
<View
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="#77f27123"
android:orientation="vertical" />
@Vaiden Android支持4位ARGB。在这种情况下,它将被解释为#77FFFFFF。如果我们使用
而不是线性布局,会不会减少内存消耗?是的,你可以使用它。当everyclass从视图中展开时