在xml文件里可以直接设置:
<shape>
<solid android:color="#F6F7F8"/>
<corners android:radius="15dp"/>/>
<padding/>
</shape>
android:background="#ffffff"
RGB表
http://blog.csdn.net/yanzi1225627/article/details/8581270
Color设置透明度—#XXxxxxxx
https://blog.csdn.net/sinat_33585352/article/details/83744673
在java代码里设置:
LinearLayout myLayout = () findViewById(R.id.linearLayout1);
myLayout.setBackgroundColor(Color.WHITE);
android:theme来设置
可以在单个Activity里设置,也可以在applicaiton里全局设置
系统自带格式
@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里加入 android:theme="@style/MyTitleBar" 再在 style.xml里加入
<style name="MyTitleBar" parent="android:Theme">
<item name="android:windowTitleSize">50dip</item>
<item name="android:windowTitleBackgroundStyle">@style/MyTitleBackground</item>
<item name="android:windowTitleStyle">@style/WindowTitle</item>
</style>
<!-- 自定义标题栏背景图 -->
<style name="MyTitleBackground" parent="android:TextAppearance.WindowTitle">
<item name="android:background">@drawable/bg_topbar</item>
</style>
<style name="WindowTitle" parent="android:TextAppearance.WindowTitle">
<item name="android:singleLine">true</item>
</style>