我想给我的小部件一个渐变背景。为此,我将以下 xml 用于渐变:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/general_listrow_background_start"
android:endColor="@color/general_listrow_background_end"
android:angle="270"/>
</shape>
并将其添加到我的布局中:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="@dimen/widget_margin"
android:padding="@dimen/widget_padding"
android:orientation="vertical"
android:background="@drawable/background_gradient">
....
</LinearLayout>
如果我在我的应用程序中使用这个布局,它会显示出来,但在我的小部件上我只得到一个白屏。我错过了什么吗?不能在 RemoteViews 中提供 xml 渐变吗?