【发布时间】:2011-08-24 00:35:13
【问题描述】:
我在将渐变背景应用到 LinearLayout 时遇到问题。
从我阅读的内容来看,这应该相对简单,但它似乎不起作用。作为参考,我正在开发 2.1-update1。
header_bg.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:startColor="#FFFF0000"
android:endColor="#FF00FF00"
android:type="linear"/>
</shape>
main_header.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:orientation="horizontal"
android:background="@drawable/header_bg">
</LinearLayout>
如果我将 @drawable/header_bg 更改为颜色 - 例如#FF0000 它工作得很好。我在这里遗漏了什么明显的东西吗?
【问题讨论】:
-
android:backgroundTint android:backgroundTintMode stackoverflow.com/a/43341289/3209132
标签: android android-layout android-linearlayout gradient