【问题标题】:Change PreferenceActivity background更改 PreferenceActivity 背景
【发布时间】:2013-12-17 09:36:49
【问题描述】:

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

这就是我实现屏幕截图的方式。这段代码放在PreferenceActivity的onCreate中。

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

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

【问题讨论】:

    标签: android layout styles themes preference


    【解决方案1】:

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

    像这样:

        <?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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-05
      • 2010-11-01
      • 2013-03-25
      • 2011-10-07
      • 2012-11-01
      • 2020-07-27
      • 2013-08-08
      相关资源
      最近更新 更多