gpt4 book ai didi

android - 更改 PreferenceActivity 背景

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:49:10 24 4
gpt4 key购买 nike

我怎样才能完全改变我的 preferenceActivity 背景的颜色?请看我的截图。在平板电脑上,窗口背景和 ListView 背景周围有一种白色边框。我不知道如何更改它的颜色/可绘制对象。我只需要让它透明。

我就是这样截屏的。此代码放在 PreferenceActivity 的 onCreate 中。

this.getListView().setBackgroundDrawable(this.getResources().getDrawable(R.drawable.splash_bg));
this.getWindow().setBackgroundDrawable(this.getResources().getDrawable(R.drawable.splash_bg));

希望我不必进入任何样式,为了简单起见,我可以在代码中访问它。 enter image description here

最佳答案

好的,您需要将布局设置为自定义布局。自定义布局的唯一要求是具有 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com