如何让项目背景和它的形状一起显示
how to make item background and it's shape display together
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="#996a151f" />
</shape>
</item>
<item android:drawable="@drawable/ic_temp_oval">
<shape android:cacheColorHint="@android:color/transparent" android:shape="oval">
<solid android:color="#00ffffff" />
<stroke android:width="1sp" android:color="#99a93435" />
</shape>
</item>
我想在可绘制图片的前面加一个边框,但是我发现图片存在时边框会消失。我可以同时拥有图片和边框吗?
你试过图层列表吗http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList
我想你想做这样的事情
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_temp_oval">
<shape android:cacheColorHint="@android:color/transparent" android:shape="oval">
<solid android:color="#00ffffff" />
<stroke android:width="1sp" android:color="#99a93435" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="#996a151f" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="#996a151f" />
</shape>
</item>
<item android:drawable="@drawable/ic_temp_oval">
<shape android:cacheColorHint="@android:color/transparent" android:shape="oval">
<solid android:color="#00ffffff" />
<stroke android:width="1sp" android:color="#99a93435" />
</shape>
</item>
我想在可绘制图片的前面加一个边框,但是我发现图片存在时边框会消失。我可以同时拥有图片和边框吗?
你试过图层列表吗http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList
我想你想做这样的事情
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_temp_oval">
<shape android:cacheColorHint="@android:color/transparent" android:shape="oval">
<solid android:color="#00ffffff" />
<stroke android:width="1sp" android:color="#99a93435" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="#996a151f" />
</shape>
</item>
</layer-list>