How do I remove the large amount of padding surrounding the content of my PreferenceActivity activity while it is in landscape orientation?
This only occurs when running the app on Android 4.0+
Here is a good image that describes my problem:
In your AndroidManifest set the activity theme like this:
<activity
android:name="com.your.package.SettingsActivity"
android:label="@string/title_activity_settings"
android:theme="@style/PrefTheme" />
Then add this to styles.xml in values
<style name="PrefTheme">
<item name="android:padding">2dp</item>
</style>
Slightly late on the answer but it might help someone else.
Thanks
Steve
Steve's answer is correct but it also sets padding for other child views. That's why I ended up putting this in onCreate()
of my PreferenceActivity:
((ViewGroup)getListView().getParent()).setPadding(0, 0, 0, 0);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.