不要在全屏模式下显示偏好屏幕Android
问题描述:
我有一个应用程序,显示一个首选项屏幕。这里是屏幕的布局:不要在全屏模式下显示偏好屏幕Android
<?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>
而且活动非常简单:
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 /布局/ 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>
变化
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);
}
}