Question

I'm using a PreferenceFragment and load the preference from xml in the onCreate-Method of the PreferenceFragment:

     @Override
     public void onCreate(Bundle savedInstanceState) 
     {
      ...
      addPreferencesFromResource(R.xml.preferences_base);
      PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences_base, false);  
      ...
     }

This is an excerpt from the preference_base.xml:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
        <CheckBoxPreference
            android:key="boolStartSettings"
            android:title="@string/prefBoolStartSettings"
            android:summary="@string/prefBoolStartSettingsSummary"
            android:defaultValue="false"/>

...

</PreferenceScreen>

This works fine and as expected in the simulator and on my Galaxy S4. Today I tested the app on a GalaxyTab and now the preferences are not displayed correctly:

Here is a screenshot from my Galaxy S4: enter image description here

and here is a screenshot from the GalaxyTab enter image description here

As you can see, there is a strange frame or border in landscape-mode in the preference-view.

Any idea why that happens and how to solve this?


EDIT:

I've implemented a preferences subscreen in my preferences now and this is shown correctly: enter image description here

If I press the up-Button to get to my main preferences page the strange frame/border is still there.

I'm afraid that will not help very much but here is an excerpt from my preferences xml with the subscreen:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
        xmlns:android="http://schemas.android.com/apk/res/android">
<!-- not shown correctly -->
...    
    <PreferenceCategory
            android:title="@string/prefKatEffectsAndAnimations">
            <PreferenceScreen
                android:key="@string/keyPrefDetails"
                android:title="@string/prefCmdDetailSettings"
                android:persistent="true">
                    <!-- shown correctly -->
                    ...
            </PreferenceScreen>
    </PreferenceCategory>
...
</PreferenceScreen>
Was it helpful?

Solution

Make sure that your activity extends Activity, not PreferenceActivity. I have the same when I use advise from here What to use instead of "addPreferencesFromResource" in a PreferenceActivity?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top