Question

I am trying to figure out why the layout of my Preference menu is displayed in a false way on 10' tablets when using it in landscape mode. It looks like the lines that are to the right of the Checkboxes are actually to the left of them. You can see this here http://imageshack.us/photo/my-images/109/schnappschuss2013052109.png/

On 7' tablets, everything works like expected to do.

My menu looks like that:

    <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory 
        android:title="@string/pref_message"
        android:key="pref_key_message_settings">
        <CheckBoxPreference
            android:key="pref_key_add_timestamp"
            android:summary="@string/pref_summary_addTimestamp"
            android:title="@string/pref_addTimestamp"
            android:defaultValue="true"/>
        <ListPreference
            android:dependency="pref_key_add_timestamp"
            android:summary="@string/pref_summary_timestamp_option"
            android:key="pref_key_timestamp_option"
            android:title="@string/pref_timestampOption"
            android:dialogTitle="@string/pref_timestampOptionDialog"
            android:entries="@array/pref_timestampArray"
            android:entryValues="@array/pref_timestampValues"
            android:defaultValue="Time" />
        <CheckBoxPreference
            android:key="pref_key_add_newline"
            android:summary="@string/pref_summary_addNewLine"
            android:title="@string/pref_addNewLine"
            android:defaultValue="true"/>
        <ListPreference
            android:dependency="pref_key_add_newline"
            android:key="pref_key_newline_option"
            android:summary="@string/pref_summary_newline_option"
            android:title="@string/pref_newLineOption"
            android:dialogTitle="@string/pref_newLineOptionDialog"
            android:entries="@array/pref_newLineArray"
            android:entryValues="@array/pref_newLineValues"
            android:defaultValue="LF" />
        <CheckBoxPreference
            android:key="pref_key_clear_text"
            android:summary="@string/pref_summary_clearText"
            android:title="@string/pref_clearText"
            android:defaultValue="false"/>
    </PreferenceCategory>
 <PreferenceCategory 
        android:title="@string/pref_storage"
        android:key="pref_key_storage_settings">
        <EditTextPreference
            android:key="pref_key_change_name"
            android:summary="@string/pref_summary_editFilename"
            android:title="@string/pref_editFilename"
            android:defaultValue="history"/>
        <CheckBoxPreference
            android:key="pref_key_add_date"
            android:summary="@string/pref_summary_addDate"
            android:title="@string/pref_addDate"
            android:defaultValue="true"/>
        <CheckBoxPreference
            android:key="pref_key_add_time"
            android:summary="@string/pref_summary_addTime"
            android:title="@string/pref_addTime"
            android:defaultValue="true"/>     
       <at.rtcmanager.ConfirmPreference
           android:key="pref_key_clear_history"
            android:summary="@string/pref_summary_clearHistory"
            android:title="@string/pref_clearHistory"/>
</PreferenceCategory>
<PreferenceCategory 
        android:title="@string/pref_time"
        android:key="pref_key_time_settings">  
        <CheckBoxPreference
            android:key="pref_key_autosend_time"
            android:summary="@string/pref_summary_austosendTime"
            android:title="@string/pref_autosendTime"
            android:defaultValue="false"/>
        <ListPreference
            android:key="pref_key_mode_sentTime"
            android:title="@string/pref_mode_sentTime"
            android:summary="@string/pref_summary_mode_sentTime"
            android:dialogTitle="@string/pref_modeSentTimeDialog"
            android:entries="@array/pref_sentTimeModeArray"
            android:entryValues="@array/pref_sentTimeValues"
            android:defaultValue="10Byte" />
</PreferenceCategory> 
<PreferenceCategory 
        android:title="@string/pref_about"
        android:key="pref_key_settings_about">  
        <Preference android:title="@string/prefs_about_app" >
            <intent android:action="AboutActivity"/>
        </Preference>

</PreferenceCategory>  
</PreferenceScreen>

and is loded with:

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Show the Up button in the action bar.
        getActionBar().setDisplayHomeAsUpEnabled(true);

        // Display the fragment as the main content.
        getFragmentManager().beginTransaction()
                .replace(android.R.id.content, new SettingsMenuFragment())
                .commit();



    }

    public static class SettingsMenuFragment extends PreferenceFragment {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            // Load the preferences from an XML resource
            addPreferencesFromResource(R.xml.app_prefs);

        }

    }
Was it helpful?

Solution

I had the same problem. My solution is to extend SettingsActivity from usual Activity, not from PreferenceActivity. But SettingsFragment should extend PreferenceFragment of course. It helped me, hope this solves your issue too.

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