偏好看起来很奇怪? (向右移一点,字体大一点)

时间:2015-04-28 03:46:48

标签: android preference

我不知道为什么DialogPreference创建的项目的位置 向右移动一点,字体大小......稍大一点?

Preference Image

我有一个NumberPickerPreference类,它扩展了DialogPreference。

package com.example
public class NumberPickerPreference extends DialogPreference{
          ......
}

和首选项的pref_general.xml

  <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
  <PreferenceCategory
    android:title="@string/header_system">

    <!-- extends DialogPreference -->
    <com.example.NumberPickerPreference
        android:key="@string/key_refresh"          
        android:title="@string/title_refresh_time"
        android:dialogTitle="@string/title_refresh_time"
        android:summary="@string/summary_refresh_time"         
        android:negativeButtonText="@string/ui_cancel"
        android:positiveButtonText="@string/ui_ok" />


    <CheckBoxPreference   
        android:title="@string/title_reconnect_unlimit" 
        android:key="@string/key_reconnect_unlimit"
        android:summaryOn="@string/summary_reconnect_unlimit"  
        android:summaryOff="@string/summary_reconnect_unlimit"   
        android:disableDependentsState="true" />

  </PreferenceCategory>
  </PreferenceScreen>

并且SettingsActivity类加载pref_general.xml

public class SettingsActivity extends Activity {
   @Override
    protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getFragmentManager().beginTransaction().replace(android.R.id.content, new GeneralPreferenceFragment()).commit();          
    }


    public static class GeneralPreferenceFragment extends PreferenceFragment {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);                     
            addPreferencesFromResource(R.xml.pref_general);
        }
    }
}

0 个答案:

没有答案