我的应用中的评论活动布局有一个圆角的可绘制背景(layout_bg_round_corners):
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/deep_orange"/>
<corners android:radius="20dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
可绘制的背景透过白色。相反,我希望它们是黑色的。
如何设置drawable的背景颜色?
这就是我设置父视图布局的方式:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/layout_bg_round_corners"
答案 0 :(得分:1)
除非我完全误解了你,否则图层列表drawable应该可以解决问题:)
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="#000000" />
</shape>
</item>
<item>
<shape>
<solid android:color="@color/deep_orange"/>
<corners android:radius="20dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</item>
</layer-list>
答案 1 :(得分:1)
嘿,你需要为相对布局赋予黑色,试试这个
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="#000000">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/layout_bg_round_corners">
答案 2 :(得分:0)
在布局xml中添加标签android:background =“颜色代码”
或者您可以通过将颜色代码替换为可绘制的ID来将背景设置为可绘制的。