2012-04-12 106 views
0

全部,Android:PreferenceActivity額外空白以下項目

我是新來使用PreferenceActivity,並最終得到它的工作。但是,我遇到的問題是,我的偏好項目後面有一個醜陋的空白區域。我嘗試應用樣式並將背景顏色設置爲黑色。但是,這並沒有奏效。任何幫助,將不勝感激。我附上了一些代碼和下面的截圖。

THX

public class EditPref extends PreferenceActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 

    addPreferencesFromResource(R.xml.preferences); 

} 

}

樣式XML代碼:

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





    </style> 

</resources> 

附着是偏好XML文件。

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

我的API 10

enter image description here

+0

你能不能附加preferences.xml文件的內容並告訴我們你正在運行哪個Android版本? – 2012-04-12 17:17:21

+0

完成。請看原始問題。 – 2012-04-12 17:27:05

+0

Theres某個電話。不幸的是,我不記得哪一個:(如果元素沒有填滿屏幕,覆蓋列表視圖會顯示灰色陰影,而不是背景。我知道它的毛病。你有沒有在另一部電話上試過這個? – HannahMitt 2012-04-12 17:30:05

回答

2

開發什麼是您的活動的聲明看起來像在ActivityManifest.xml?更具體地說,你使用什麼主題?我發佈了一個解決方案到related SO post,但基本上你應該能夠通過設置overScrollFooter@null爲你的API級別10+上的ListView擺脫醜陋的空白空間。

我有同樣的問題,只是寫了blog post有更詳細一點,但嘗試使用這個(代你使用父主題,當然):

RES /價值/風格.XML

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

RES /值-V10/styles.xml

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

設置你的主題中使用新的ListView樣式:

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

然後在您的AndroidManifest.xml中,將EditPref Activity聲明爲使用新主題。一些沿線的:

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

這樣做了,謝謝。 – 2012-06-05 03:55:05