首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >改变PreferenceActivity背景

改变PreferenceActivity背景
EN

Stack Overflow用户
提问于 2013-12-01 18:05:21
回答 1查看 3.1K关注 0票数 4

我如何能够完全改变我的preferenceActivity背景的颜色?请看我的截图。在平板电脑上,窗口背景和列表视图背景周围有一个白色边框。我想不出如何改变它的颜色/颜色。我只需要让它透明。

我就是这样完成截图的。此代码被放置在onCreate的PreferenceActivity中。

代码语言:javascript
复制
this.getListView().setBackgroundDrawable(this.getResources().getDrawable(R.drawable.splash_bg));
this.getWindow().setBackgroundDrawable(this.getResources().getDrawable(R.drawable.splash_bg));

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-08 14:11:05

好的,您需要将布局设置为自定义布局。定制布局的唯一要求是有一个id为android的列表视图:id/ list

就像这样:

代码语言:javascript
复制
    <?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>

比你的onCreate of PrefActivity:

代码语言:javascript
复制
    this.setContentView(R.layout.pref_act);
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20315412

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档