设置背景的方法 不错的方法
来源:互联网 发布:宝钗扑蝶赏析 知乎 编辑:程序博客网 时间:2024/04/19 15:51
一、在xml文件里可以直接设置:
android:background="#ffffff"
其他颜色可以看这里;http://blog.csdn.net/yanzi1225627/article/details/8581270
二、在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">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>
这里的parent是继承于android:Theme,所以在下面的样式里,只能是window开头的样式才起作用,所有样式请参考\sdk\docs\reference\android\R.attr.html,
也可以设置windowTitleBackgroundStyle 为@style/MyTitleBackground,这样就可以在MyTitleBackground里,设置背景图。
0 0
- 设置背景的方法 不错的方法
- 设置Activity背景的方法
- 设置对话框背景颜色的方法
- 设置对话框背景的几种方法
- Notepad++背景颜色的设置方法
- Notepad++背景颜色的设置方法
- 有关视图背景的设置方法
- 应用程序设置统一背景的实现方法
- 网站宽背景的设置方法
- swing 设置背景颜色渐变的方法
- WebView背景无法透明的设置方法
- pyscripter设置黑色背景的方法
- Android 动态设置Activity背景的方法
- 设置view渐变背景的工具方法
- Android自定义背景的设置方法
- Android设置背景颜色的方法
- Button设置弧度背景的方法
- 不错的读书方法
- oracle创建表空间
- QT在windows下的安装与配置
- [Cocos2d-x v3.x官方文档]基础概念介绍——导演、场景、层、精灵 分享0
- Sublime Text2编译运行C++的配置
- unity3d 2d游戏如何导出IOS项目
- 设置背景的方法 不错的方法
- Struts2结合CKEditor需要注意的地方
- Exception in thread "http-bio-8080-exec-11" java.lang.OutOfMemoryError: PermGen space
- 黑马程序员----GUI与网络编程
- 终止Android中HandlerThread的方法
- Linux内核30题
- Qt Creator的配置和开发初步测试
- MySQL之基础-2 MySQL安装介绍之5.6版本Cmake安装
- [Cocos2d-x v3.x官方文档]Cocos2d-x 3.0坐标系详解 分享0