不同高度的偏好

时间:2016-04-03 12:58:08

标签: java android preferences preferenceactivity preference

我有main.java:

public class Main extends PreferenceActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.activity);
    PreferenceScreen screen = this.getPreferenceScreen();

    Preference preference;
    preference = new Preference(screen.getContext());
    preference.setSummary("Hi");
    screen.addPreference(preference);
    preference = new Preference(screen.getContext());
    preference.setSummary("Hi");
    screen.addPreference(preference);
    preference = new Preference(screen.getContext());
    preference.setSummary("Hi");
    screen.addPreference(preference);
    preference = new Preference(screen.getContext());
    preference.setSummary("Hi");
    screen.addPreference(preference);
    preference = new Preference(screen.getContext());
    preference.setSummary("My long text");
    screen.addPreference(preference);
    preference = new Preference(screen.getContext());
    preference.setSummary("My long text");
    screen.addPreference(preference);
}

我的activity.xml:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

</PreferenceScreen>

当我在列表顶部滚动时:

enter image description here

当我在列表底部滚动时:

enter image description here

ScrollBar在滚动期间发生变化。当我将所有首选项设置为相同的高度时,一切都很好。

0 个答案:

没有答案