转载自:Android 设置背景色或者主题。
Android设置布局背景为白色的三种方法:
一、在xml文件里可以直接设置:

android:background="#ffffff"//白色

其他颜色可以看Android开发:setAlpha()方法和常用RGB颜色表—-颜色, r g b分量数值(int), 16进制表示 一一对应
二、在Java文件里设置:

LinearLayout myLayout = () findViewById(R.id.linearLayout1);myLayout.setBackgroundColor(Color.WHITE);

三、在AndroidManifest.xml里利用android:theme来设置,这个命令还是很强大的,如下所示:
theme的设置 可以设置为系统自带的格式,也可以自定义格式。

A: 系统自带格式

    @android:style/Theme.Black  //背景黑色-有标题-非全屏   @android:style/Theme.Black.NoTitleBar //背景黑色-无标题-非全屏   @android:style/Theme.Black.NoTitleBar.Fullscreen //背景黑色-无标题-全屏显示   @android:style/Theme.Dialog //对话框显示   @android:style/Theme.InputMethod   @android:style/Theme.Light    //背景白色-有标题-非全屏   @android:style/Theme.Light.NoTitleBar //背景白色-无标题-非全屏   @android:style/Theme.Light.NoTitleBar.Fullscreen //背景白色-无标题-全屏显示   @android:style/Theme.Light.Panel   @android:style/Theme.Light.WallpaperSettings //背景透明   @android:style/Theme.NoDisplay   @android:style/Theme.Translucent.NoTitleBar.Fullscreen //半透明、无标题栏、全屏   @android:style/Theme.Wallpaper.NoTitleBar.Fullscreen

可以在单个Activity里设置,也可以在applicaiton里全局设置。比如:

<activity android:screenOrientation="portrait" android:name=".ui.RegisterActivity" android:theme="@android:style/Theme.NoTitleBar">activity>

B:也可以自定义
在activity里加入 android:theme=”@style/MyTitleBar” 再在 style.xml里加入

   <style name="MyTitleBar" parent="android:Theme">        <item name="android:windowTitleSize">50dipitem>         <item name="android:windowTitleBackgroundStyle">@style/MyTitleBackground        "android:windowTitleStyle">@style/WindowTitle  style>   <style name="MyTitleBackground" parent="android:TextAppearance.WindowTitle">   <item name="android:background">@drawable/bg_topbar  style>  <style name="WindowTitle" parent="android:TextAppearance.WindowTitle">   <item name="android:singleLine">trueitem>  style>

这里的parent是继承于android:Theme,所以在下面的样式里,只能是window开头的样式才起作用,所有样式请参考\sdk\docs\reference\android\R.attr.html,

也可以设置windowTitleBackgroundStyle 为@style/MyTitleBackground,这样就可以在MyTitleBackground里,设置背景图。

来自: http://www.cnblogs.com/android100/p/android-setbackground-white.html

更多相关文章

  1. 填坑总结:通过selector的android:state_checkable和android:state
  2. 浅谈android的selector,背景选择器(看着有用就转载了)
  3. Android之主题与样式

随机推荐

  1. iOS 与 Android 生命周期对比
  2. 单项选择RadioButton和多项选择CheckBox
  3. Android腾讯微博客户端开发一:在下方的Ta
  4. FragmentTabHost使用
  5. Android Studio Error 安装后Gradle:reso
  6. ViewBinding的简单使用
  7. Android广播接收器BroadcastReceiver——
  8. Android(安卓)四大组件:这是一份全面 & 详
  9. android 传感器的使用
  10. 【Android自学笔记】Android中的Log小技