创建与ICS设置/首选项背景相同的活动

Waz*_*_Be 4 android themes background

我正在开发一款适用于ICS的应用程序,我希望我的Activity具有与设置相同的背景,并具有很酷的渐变效果.

我尝试过Theme.DeviceDefault和其他一些,但我无法得到它.

这可能还是我应该忘记?

在此输入图像描述

dpa*_*nas 13

直接自己创建此应用程序背景相对简单.

绘制/ app_background_ics.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
    android:angle="270"
    android:startColor="@color/ics_background_start"
    android:endColor="@color/ics_background_end"
    android:type="linear" />
</shape>
Run Code Online (Sandbox Code Playgroud)

值/ colors.xml

<?xml version="1.0" encoding="UTF-8"?>
<resources>
   <color name="ics_background_start">#ff020202</color>
   <color name="ics_background_end">#ff272D33</color>
</resources>
Run Code Online (Sandbox Code Playgroud)

然后将app_background_ics drawable作为背景添加到主视图中(在此示例中为ListView).不要忘记透明的android:cacheColorHint,以避免在ListView中滚动时出现黑色背景

  <ListView android:id="@+id/video_list"
  android:layout_width="fill_parent"
  android:layout_height="0dip"
  android:layout_weight="1" 
  android:dividerHeight="2dip"
  android:background="@drawable/app_background_ics"
  android:cacheColorHint="#00000000"/> 
Run Code Online (Sandbox Code Playgroud)