创建一个可绘制文件,以使分隔 [英] creating a drawable file to make a separator
本文介绍了创建一个可绘制文件,以使分隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面的code,以显示我的活动分隔观点:
I'm using the following code to display a separator view in my activity:
<View
android:id="@+id/view"
android:layout_width="2dp"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_toLeftOf="@id/signoutbutton"
android:background="@drawable/separator" />
我的separator.xml文件如下:
My separator.xml file is as follows:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<stroke
android:height="54dp"
android:width="1dp"
android:color="#FFFFFF" />
<solid android:color="#FFFFFF" />
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<stroke
android:height="54dp"
android:width="1dp"
android:color="@color/blue" />
<solid android:color="@color/blue" />
</shape>
</item>
</layer-list>
不过,我实现这个
however, I am achieving this
现在的问题是,只有蓝色显示,而不是白色的,因为我在绘制文件中所指出的。我怎样才能解决这个?
The problem is that only the blue color is shown and not the white as I had stated in the drawable file. How can I correct this?
推荐答案
您应该尝试使用如下:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<gradient
android:endColor="#FFFFFF"
android:startColor="@color/blue"
android:angle="90" />
</shape>
</item>
</layer-list>
有关更多资讯 LayerList
希望这有助于你
这篇关于创建一个可绘制文件,以使分隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文