Android中怎么去除标题栏详解
怎么出去标题栏,我再另一个博客中亦有实例
在这里再详细的解释一下,也让自己能更加巩固最简单也是小重要的东西。
这里有两种方法是比较好的。。。
第一种:
首先,在values中建一个theme.xml
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- name 是Style的名称,parent 继承那个父类样式 -->
<style name="theme_fullScreen" parent="android:Theme.Black">
<item name="android:windowNoTitle">true</item>
<!-- 设置无标题 -->
<item name="android:windowFullscreen">?android:windowNoTitle</item>
<!-- 是否填充慢屏幕,引用android:windowNoTitle 的值 ?android:windowNoTitle,取决于android:windowNoTitle的值 -->
</style>
</resources>
name 定义的是 Style的名称
parent 继承那个父类样式
然后,在AndroidManifest.xml中定义activity的属性theme
代码如下:
<activity
android:name=".Index"
android:theme="@style/theme_fullScreen"
>
</activity>
以后每个Activity中都加入这样的属性就可以了,网上有很多解决方案,不过我个人常用着一个,方便简单。
第二种:
直接在Style中定义一个主题既可以了。
<item name="android:windowNoTitle">true</item>
第三种:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); //设置标题栏
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
一开始进入Activity时不是全屏的,点击按钮时就全屏,动态隐藏标题栏去除状态栏的方法:
 public void setScreen(){
                    //if search dialog is open, we should quit full screen.
        if(isFullScreen ){
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
                isFullScreen=false;
        }else{
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                isFullScreen=true;
        }
在Android的API中
Styles and Themes
IN THIS DOCUMENT
SEE ALSO
- Style and Theme Resources
 R.stylefor Android styles and themesR.attrfor all style attributes
A style is a collection of properties that specify the look and format for a View or window. A style can specify properties such as height, padding, font color, font size, background color, and much more. A style is defined in an XML resource that is separate from the XML that specifies the layout.
Styles in Android share a similar philosophy to cascading stylesheets in web design—they allow you to separate the design from the content.
For example, by using a style, you can take this layout XML:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#00FF00"
android:typeface="monospace"
android:text="@string/hello"/>
And turn it into this:
<TextView
style="@style/CodeFont"
android:text="@string/hello"/>
All of the attributes related to style have been removed from the layout XML and put into a style definition calledCodeFont, which is then applied with the style attribute. You'll see the definition for this style in the following section.
A theme is a style applied to an entire Activity or application, rather than an individual View (as in the example above). When a style is applied as a theme, every View in the Activity or application will apply each style property that it supports. For example, you can apply the same CodeFont style as a theme for an Activity and then all text inside that Activity will have green monospace font.
Defining Styles
To create a set of styles, save an XML file in the res/values/ directory of your project. The name of the XML file is arbitrary, but it must use the .xml extension and be saved in the res/values/ folder.
The root node of the XML file must be <resources>.
For each style you want to create, add a <style> element to the file with a name that uniquely identifies the style (this attribute is required). Then add an <item> element for each property of that style, with a name that declares the style property and a value to go with it (this attribute is required). The value for the <item> can be a keyword string, a hex color, a reference to another resource type, or other value depending on the style property. Here's an example file with a single style:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<stylename="CodeFont"parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
Each child of the <resources> element is converted into an application resource object at compile-time, which can be referenced by the value in the <style> element's name attribute. This example style can be referenced from an XML layout as @style/CodeFont (as demonstrated in the introduction above).
The parent attribute in the <style> element is optional and specifies the resource ID of another style from which this style should inherit properties. You can then override the inherited style properties if you want to.
Remember, a style that you want to use as an Activity or application theme is defined in XML exactly the same as a style for a View. A style such as the one defined above can be applied as a style for a single View or as a theme for an entire Activity or application. How to apply a style for a single View or as an application theme is discussed later.
Inheritance
The parent attribute in the <style> element lets you specify a style from which your style should inherit properties. You can use this to inherit properties from an existing style and then define only the properties that you want to change or add. You can inherit from styles that you've created yourself or from styles that are built into the platform. (See Using Platform Styles and Themes, below, for information about inheriting from styles defined by the Android platform.) For example, you can inherit the Android platform's default text appearance and then modify it:
<stylename="GreenText"parent="@android:style/TextAppearance">
<item name="android:textColor">#00FF00</item>
</style>
If you want to inherit from styles that you've defined yourself, you do not have to use the parent attribute. Instead, just prefix the name of the style you want to inherit to the name of your new style, separated by a period. For example, to create a new style that inherits the CodeFont style defined above, but make the color red, you can author the new style like this:
<stylename="CodeFont.Red">
<item name="android:textColor">#FF0000</item>
</style>
Notice that there is no parent attribute in the <style> tag, but because the name attribute begins with theCodeFont style name (which is a style that you have created), this style inherits all style properties from that style. This style then overrides the android:textColor property to make the text red. You can reference this new style as @style/CodeFont.Red.
You can continue inheriting like this as many times as you'd like, by chaining names with periods. For example, you can extend CodeFont.Red to be bigger, with:
<stylename="CodeFont.Red.Big">
<item name="android:textSize">30sp</item>
</style>
This inherits from both CodeFont and CodeFont.Red styles, then adds the android:textSize property.
Note: This technique for inheritance by chaining together names only works for styles defined by your own resources. You can't inherit Android built-in styles this way. To reference a built-in style, such asTextAppearance, you must use the parent attribute.
Style Properties
Now that you understand how a style is defined, you need to learn what kind of style properties—defined by the<item> element—are available. You're probably familiar with some already, such as layout_width andtextColor. Of course, there are many more style properties you can use.
The best place to find properties that apply to a specific View is the corresponding class reference, which lists all of the supported XML attributes. For example, all of the attributes listed in the table of TextView XML attributescan be used in a style definition for a TextView element (or one of its subclasses). One of the attributes listed in the reference is android:inputType, so where you might normally place the android:inputType attribute in an<EditText> element, like this:
<EditText
android:inputType="number"
... />
You can instead create a style for the EditText element that includes this property:
<stylename="Numbers">
<item name="android:inputType">number</item>
...
</style>
So your XML for the layout can now implement this style:
<EditText
style="@style/Numbers"
... />
This simple example may look like more work, but when you add more style properties and factor-in the ability to re-use the style in various places, the pay-off can be huge.
For a reference of all available style properties, see the R.attr reference. Keep in mind that all View objects don't accept all the same style attributes, so you should normally refer to the specific View class for supported style properties. However, if you apply a style to a View that does not support all of the style properties, the View will apply only those properties that are supported and simply ignore the others.
Some style properties, however, are not supported by any View element and can only be applied as a theme. These style properties apply to the entire window and not to any type of View. For example, style properties for a theme can hide the application title, hide the status bar, or change the window's background. These kind of style properties do not belong to any View object. To discover these theme-only style properties, look at the R.attrreference for attributes that begin with window. For instance, windowNoTitle and windowBackground are style properties that are effective only when the style is applied as a theme to an Activity or application. See the next section for information about applying a style as a theme.
Note: Don't forget to prefix the property names in each <item> element with the android: namespace. For example: <item name="android:inputType">.
Android中怎么去除标题栏详解的更多相关文章
- Android中的windowSoftInputMode属性详解
		
这篇文章主要介绍了Android中的windowSoftInputMode属性详解,本文对windowSoftInputMode的9个属性做了详细总结,需要的朋友可以参考下 在前面的一篇文章中 ...
 - Android中Service的使用详解和注意点(LocalService)
		
Android中Service的使用详解和注意点(LocalService) 原文地址 开始,先稍稍讲一点android中Service的概念和用途吧~ Service分为本地服务(LocalServ ...
 - Android中SurfaceView的使用详解
		
Android中SurfaceView的使用详解 http://blog.csdn.net/listening_music/article/details/6860786 Android NDK开发 ...
 - Android中Canvas绘图基础详解(附源码下载) (转)
		
Android中Canvas绘图基础详解(附源码下载) 原文链接 http://blog.csdn.net/iispring/article/details/49770651 AndroidCa ...
 - Android中Application类的详解:
		
Android中Application类的详解: 我们在平时的开发中,有时候可能会须要一些全局数据.来让应用中的全部Activity和View都能訪问到.大家在遇到这样的情况时,可能首先会想到自定义一 ...
 - Android 中的消息传递,详解广播机制
		
--------------------------------------广播机制简介--------------------------------------------- Android中的广 ...
 - Android中的sharedUserId属性详解
		
在Android里面每个app都有一个唯一的linux user ID,则这样权限就被设置成该应用程序的文件只对该用户可见,只对该应用程序自身可见,而我们可以使他们对其他的应用程序可见,这会使我们用到 ...
 - Android中Activity启动模式详解
		
在Android中每个界面都是一个Activity,切换界面操作其实是多个不同Activity之间的实例化操作.在Android中Activity的启动模式决定了Activity的启动运行方式. An ...
 - Android中数据库的操作流程详解
		
Android中数据库的操作方法: 1.Android平台提供了一个数据库辅助类来创建或打开数据库. 这个辅助类继承自SQLiteOpenHelper类.继承和扩展SQLiteOpenHelper类主 ...
 
随机推荐
- WebGL 支持测试,并已支持的浏览器版本摘要
			
WebGL 支持情况检測与已支持浏览器版本号汇总 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公 ...
 - ASP.NET Identity 身份验证和基于角色的授权
			
ASP.NET Identity 身份验证和基于角色的授权 阅读目录 探索身份验证与授权 使用ASP.NET Identity 身份验证 使用角色进行授权 初始化数据,Seeding 数据库 小结 在 ...
 - 深入了解setInterval方法
			
相信大家对setInterval方法肯定非常熟悉,但不少人对其缺乏深入的了解,致使当一个flash里有多个setInterval的时候就容易混淆,该清除的间隔lID没有清除,不该清除的时候却清除了.对 ...
 - oracle_面试题01
			
完成下列操作,写出相应的SQL语句 创建表空间neuspace,数据文件命名为neudata.dbf,存放在d:\data目录下,文件大小为200MB,设为自动增长,增量5MB,文件最大为500MB. ...
 - linux_vim_最佳快捷键
			
如何使用vi文本编辑器 vi由比尔·乔伊(Bill Joy)撰写,所有UNIX like均默认安装此文本编辑器.详细简介请点击维基中文. 1.首先复制一个文件到/tmp目录(本例中为复制根目录 ...
 - Linux报too many open files的解决方案
			
今天系统中有一台服务器出现异常,有时连简单的shell命令都无法执行,各种奇怪的报错,有的时候又可以成功执行 如: -bash: error while loading shared librarie ...
 - Cookie基础
			
周末百度笔试,答得题都会,就是不仔细不心细,提前一个小时交卷子,想起来就已经晚了.问了一个cookie的问题,我SB的蒙住了,于是乎,似乎是跪掉了,回来后总结了下Cooke的相关问题.###获取coo ...
 - 【百度地图API】手机浏览器抓包工具及其使用方法
			
原文:[百度地图API]手机浏览器抓包工具及其使用方法 摘要:为了测试地图API在手机浏览器上的性能,需要给手机浏览器设置代理.通过代理,我们可以在PC上获取到抓包数据.进而对性能做进一步分析. -- ...
 - my97  日期控件
			
官网:http://www.my97.net/ 好多广告啊! 文档地址: http://www.mysuc.com/test/My97DatePicker/
 - centos7的安装
			
初装centos7还是在九月份,那时候关于win7 下centos7硬盘安装的资料很少,现在就好多, 在这里备份下东西吧 首先是安装的时候,关于找从那个地方找image的问题. hda ,sda分别表 ...