我怎样才能完全改变我的 preferenceActivity 背景的颜色?请看我的截图。在平板电脑上,窗口背景和 ListView 背景周围有一种白色边框。我不知道如何更改它的颜色/可绘制对象。我只需要让它透明。
我就是这样截屏的。此代码放在 PreferenceActivity 的 onCreate 中。
this.getListView().setBackgroundDrawable(this.getResources().getDrawable(R.drawable.splash_bg));
this.getWindow().setBackgroundDrawable(this.getResources().getDrawable(R.drawable.splash_bg));
希望我不必进入任何样式,为了简单起见,我可以在代码中访问它。
最佳答案
好的,您需要将布局设置为自定义布局。自定义布局的唯一要求是具有 id 为 android:id/list 的 ListView
像这样:
<?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="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:background="@drawable/DRAWABLE HERE"
>
<ListView android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@android:id/list"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
/>
</LinearLayout>
比在 PrefActivity 的 onCreate 中:
this.setContentView(R.layout.pref_act);
关于android - 更改 PreferenceActivity 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20315412/