我有一个应用程序,它显示了一个首选项屏幕。这是屏幕的布局:
<?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);
}
}
你可以看到,这只是一个项目。我尝试了不同的方式直接显示没有偏好的铃声首选项类别,或者不全屏显示此屏幕,但没有任何反应。您是否知道如何使这个屏幕看起来更好更小?
答案 0 :(得分:0)
创建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>
改变您的活动
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);
}
}