Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an Activity with the same background than ICS settings / Preferences

I am working on an app for ICS and I would like my Activity to have the same background than the settings, with the cool gradient.

I tried Theme.DeviceDefault and some other, but I cannot get it.

Is that possible or should I forget?

enter image description here

like image 736
Waza_Be Avatar asked Dec 13 '22 05:12

Waza_Be


1 Answers

It is relatively simple to create this app background directly yourself.

drawable/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>

values/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>

Then add the app_background_ics drawable as a background to your main view (in this example ListView). Do not forget a transparent android:cacheColorHint in order to avoid a black background when scrolling in the 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"/> 
like image 95
dparnas Avatar answered May 19 '23 07:05

dparnas