ControlAltDelete
ControlAltDelete

Reputation: 3724

Android: PreferenceActivity Extra White Space Below Items

All,

I am new to using the PreferenceActivity and ended up getting it to work. However, the issue I am having is that there is an ugly white space after my preference items. I tried applying a style and setting the background color to black. However, this did not work. Any help would be appreciated. I attached some code and a screenshot below.

Thx

public class EditPref extends PreferenceActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.preferences);

}

}

The style xml code:

  <?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="editPref">
       <item name = "android:background">#FF000000</item>





    </style>

</resources>

attached is the preference xml file.

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android">
    <CheckBoxPreference
        android:key="checkbox"
        android:title="Checkbox Preference"
        android:summary="Check it on, check it off" />
    <RingtonePreference
        android:key="ringtone"
        android:title="Ringtone Preference"
        android:showDefault="true"
        android:showSilent="true"

        android:summary="Pick a tone, any tone" />
</PreferenceScreen>

I am developing for API 10.

enter image description here

Upvotes: 0

Views: 851

Answers (1)

areyling
areyling

Reputation: 2191

What does your Activity declaration look like in the ActivityManifest.xml? More specifically, what theme are you using? I posted a solution to a related SO post, but basically you should be able to get rid of the ugly white space by setting overScrollFooter to @null for your ListViews on API Level 10+.

I was having the same issue and just wrote a blog post with a little more detail, but try using this (substituting the theme you're using for the parent, of course):

res/values/styles.xml

<style name="MyListView" parent="@android:style/Widget.ListView">
</style>

res/values-v10/styles.xml

<style name="MyListView" parent="@android:style/Widget.ListView">
    <item name="android:overScrollFooter">@null</item>
</style>

Set your theme to use the new ListView style:

<style name="Theme.MyPreferences" parent="android:Theme.Holo">
    <item name="android:listViewStyle">@style/MyListView</item>
</style>

And in your AndroidManifest.xml, declare the EditPref Activity to use the new theme. Something along the lines of:

<activity
    android:name=".EditPref"
    android:theme="@style/Theme.MyPreferences" /> 

Upvotes: 2

Related Questions