使用
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FFFF0000"
android:endColor="#80FF00FF"
android:angle="45"/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp" />
<corners android:radius="8dp" />
</shape>
来自http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
每当我将其设置为任何视图的背景时,它总是将背景变为灰色。
xml在res / drawable中,我尝试了指南中使用的两种方法。
有人可以解释为什么它不起作用。
答案 0 :(得分:-1)
使用此代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#00FFBB"
android:endColor="#FFEEAA"
/>
<padding android:left="7dp"
android:top="7dp"
android:right="7dp"
android:bottom="7dp" />
<corners android:radius="8dp" />
</shape>
答案 1 :(得分:-1)
不知道我是如何修复的,但我复制了我的布局,删除了它们,然后将它们粘贴回来然后清理了项目(我经常这样做)并修复了问题。