android自定义标题以及全屏设置

来源:互联网 发布:2017年要死多少淘宝店 编辑:程序博客网 时间:2024/06/17 17:03

一 、android标题自定义

  1. 在manifest文件中添加android:theme="@style/infomanage_title"设置标题格式
  2. <pre name="code" class="html"><style name="CustomWindowTitleBackground">         <item name="android:background">#0099ff</item>  </style>  
  3. <style name="infomanage_title" parent="android:Theme">       <item name="android:windowTitleSize">50dp</item>       <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>  </style> 
    在styles中添加以上代码,设置标题的背景色字体大小等格式

  4. 在setContentView(R.layout.XXX);之前加代码 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // 自定义标题
  5. 在setContentView(R.layot.XXX);之后加上getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.title_layout); // 为标题设置layout布局
  6. 在后面可以直接获取控件(和R.layout.XXX获取一样),然后就可以自己随意处理了

二、android设置无标题,设置全屏

1. android设置无标题

在setContentView(R.layout.XXX);之前添加下面代码

// 无标题
requestWindowFeature(Window.FEATURE_NO_TITLE);

2.android设置全屏

在setContentView(R.layout.XXX);之前添加下面代码

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

0 0
原创粉丝点击