我有一个应用程序,它显示首选项屏幕。这是屏幕布局:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<PreferenceCategory
android:summary="Alarm sound"
android:title="Select Sound">
<RingtonePreference
android:id="@+id/ringtone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:key="Alarm"
android:ringtoneType="notification|alarm"
android:showDefault="true"
android:summary="Alarm" />
</PreferenceCategory>
</PreferenceScreen>
Activity 非常简单:
package zabolotnii.pavel.timer;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class SoundSelect extends PreferenceActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.sound_select);
}
}
可以看到,只有一项需要设置。我尝试了不同的方法来直接显示没有首选项类别的铃声首选项,或者不全屏显示此屏幕,但没有任何反应。您知道如何让这个屏幕看起来更好、更小吗?
最佳答案
创建 res/layout/preference.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
您的 Activity 发生变化
package zabolotnii.pavel.timer;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class SoundSelect extends PreferenceActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.preference);
addPreferencesFromResource(R.layout.sound_select);
}
}
关于java - Android 全屏模式下不显示首选项屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25569748/