在形状边框xml

我正在尝试使用drawable来使用button。 我希望它有这个着色,周围有一个2px的边框。

一切正常,除非我不能让边框显示出来…

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="@color/bar_clicked_dark" android:endColor="@color/bar_clicked_light" android:angle="90"/> <corners android:bottomLeftRadius="0dp" android:topLeftRadius="15dp" android:bottomRightRadius="15dp" android:topRightRadius="0dp" /> <stroke android:width="2px" color="#ff00ffff" /> </shape> 

看起来你忘记了颜色属性的前缀。 尝试

  <stroke android:width="2px" android:color="#ff00ffff"/> 

如果你想在一个形状的xml边框。 你需要使用:

对于外部边框,您需要使用:

 <stroke/> 

对于内部背景,您需要使用:

 <solid/> 

如果你想设置angular落,你需要使用:

 <corners/> 

如果你想在边界和内部元素之间填充,你需要使用:

 <padding/> 

这是一个使用上述项目的形状xml示例。 这个对我有用

 <shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="2dp" android:color="#D0CFCC" /> <solid android:color="#F8F7F5" /> <corners android:radius="10dp" /> <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" /></shape> 
Interesting Posts