本文围绕以下五个部分展开:

一、requestWindowFeature()
二、FEATURE_CUSTOM_TITLE:自定义标题
三、FEATURE_INDETERMINATE_PROGRESS
四、FEATURE_LEFT_ICON
五、FEATURE_NO_TITLE






一、requestWindowFeature()

我们在开发Android应用程序时经常会需要软件全屏显示、自定义标题(使用按钮等控件)或其他的需求,因此需要掌握Android应用程序窗体显示的方法。

一个重要方法就是:requestWindowFeature(featrueId)。它的功能是启用窗体的扩展特性,参数是Window类中定义的常量。





二、FEATURE_CUSTOM_TITLE:自定义标题

        // 自定义标题。当需要自定义标题时必须指定。如:标题是一个按钮时        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);        setContentView(R.layout.activity_main);        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.customtitle);


customtitle.xml。

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="horizontal">    <ImageView android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:src="@mipmap/ic_launcher"/>    <TextView android:id="@+id/text"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="文本" /></LinearLayout>






三、FEATURE_INDETERMINATE_PROGRESS

        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);        setContentView(R.layout.activity_main);        getWindow().setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS, R.layout.progress);        // 必须得加上否则显示不出效果 可以通过这个在以后设置显示或隐藏        setProgressBarIndeterminateVisibility(true);


progress.xml。

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:orientation="vertical">    <ProgressBar android:id="@+id/progress"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center_vertical"        style="?android:attr/progressBarStyleSmallTitle">    </ProgressBar></LinearLayout>






四、FEATURE_LEFT_ICON

        requestWindowFeature(Window.FEATURE_LEFT_ICON);        setContentView(R.layout.activity_main);        getWindow().setFeatureInt(Window.FEATURE_LEFT_ICON, R.mipmap.ic_launcher);






五、FEATURE_NO_TITLE

        requestWindowFeature(Window.FEATURE_NO_TITLE);        setContentView(R.layout.activity_main);        // 加上这句设置为全屏 不加则只隐藏title          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,                WindowManager.LayoutParams.FLAG_FULLSCREEN);









整理时参考:
http://www.cnblogs.com/salam/archive/2010/11/30/1892143.html
http://zhanhao.iteye.com/blog/1174914

更多相关文章

  1. Android应用程序用真机调试步骤
  2. 【android】下载文件至本应用程序的file文件夹或者sdcard
  3. Android(安卓)如何保持屏幕长亮?
  4. android去除标题栏及状态栏
  5. 用PC应用程序通过USB读写Andriod里面的数据
  6. android去除标题栏-------全屏运行AND 无标题栏 总结
  7. Android(安卓)SDK,ADT,API 版本的对应关系
  8. Android(安卓)ToolBar
  9. Spring Roo

随机推荐

  1. 二、PocketSphinx-Android编译与运行
  2. [Android]自定义简易版日历控件
  3. Android(安卓)View的second layout pass
  4. android2.3 api demo 学习系列(20)--App/Me
  5. Android(安卓)最常用的快速开发工具类
  6. android获取网络图片过大的问题
  7. Android中读取文本文件中内容的方法
  8. Android(安卓)使用jsoup 进行数据抓取
  9. Android(安卓)8.1预置apk为可卸载
  10. Android开发中颜色的自定义方法