zoukankan      html  css  js  c++  java
  • Android开发UI之去掉title bar

    去掉屏幕上的title bar有3个方法:

    1.java代码实现:

    1 @Override
    2 publicvoid onCreate(Bundle savedInstanceState) {
    3 super.onCreate(savedInstanceState);
    4 
    5 requestWindowFeature(Window.FEATURE_NO_TITLE);
    6 
    7        setContentView(R.layout.main);
    8 //...
    9 }

    2.自定义style配置文件

    在 esvalues里面的style.xml添加:

    1 <?xmlversion="1.0"encoding="utf-8"?>
    2 <resources>
    3 <stylename="NoTitle"parent="android:Theme">
    4 <itemname="android:windowNoTitle">true</item>
    5 </style>
    6 </resources>

    然后在AndroidManifest.xml文件里,给需要去掉title bar的activity的节点上加上android:theme="@style/NoTitle,代码如下:

    1 <activityandroid:name=".MainActivity"
    2 android:configChanges="orientation|keyboardHidden"
    3 android:theme="@style/NoTitle"/>

    3.直接在AndroidManifest.xml中进行修改

    原来我们可以无需自定义style配置的,直接调用系统的就行了:

    1 <activityandroid:name=".MainActivity"
    2 android:configChanges="orientation|keyboardHidden"
    3 android:theme="@android:style/Theme.NoTitleBar"/>

    如果我们要设置整个Application都去掉title bar,那么就设置application:

    1 <applicationandroid:icon="@drawable/lightbulb"android:label="@string/app_name"
    2 android:theme="@android:style/Theme.NoTitleBar">
  • 相关阅读:
    hdu2844 Coins 多重背包
    Android笔记之网络状态推断
    TinyAdmin前端展现框架
    DeepLearning to digit recognizer in kaggle
    Oracle学习(十二):存储过程/存储函数
    【BZOJ1029】【JSOI2007】【建筑抢修】【贪心+堆】
    【HDOJ 1009】 CRB and String
    一些类的说明
    常用指令
    常用英语词汇
  • 原文地址:https://www.cnblogs.com/liyiran/p/4656785.html
Copyright © 2011-2022 走看看