android - 10 英寸平板电脑上的偏好菜单

标签 android menu tablet preference

我试图弄清楚为什么在横向模式下使用我的首选项菜单的布局在 10 英寸平板电脑上以错误的方式显示。看起来复选框右侧的线实际上位于它们的左侧。你可以在这里看到这个http://imageshack.us/photo/my-images/109/schnappschuss2013052109.png/

在 7 英寸平板电脑上,一切都按预期进行。

我的菜单看起来像这样:

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

并装有:

@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);

        }

    }

最佳答案

我也遇到了同样的问题。我的解决方案是从常用的 Activity 扩展 SettingsActivity,而不是从 PreferenceActivity 扩展。但是 SettingsFragment 当然应该扩展 PreferenceFragment。它对我有帮助,希望这也能解决您的问题。

关于android - 10 英寸平板电脑上的偏好菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16665115/

相关文章:

android - 由于未接受许可协议(protocol),run-android 无法运行

forms - 在 Xamarin Forms 中创建菜单叠加层

android - 使用 XML 的特定于平板电脑的 ImageView 宽度/高度/等值?

android - 如何从 Android 设备访问本地主机网站

java - 结果在 Android 中不是随机的

android - 我正在尝试在 flutter 中使用中心小部件,但由于某些未知原因它无法正常工作,请帮助我

显示一个框的 JQuery 菜单

html - 当窗口最小化时,CSS 菜单会折叠

testing - 移动和平板设备测试

android - 在 Android 平板电脑 (HTC Flyer) 上查看崩溃日志