zoukankan      html  css  js  c++  java
  • Android UI ActionBar功能-自动隐藏 Action Bar

    为了使ActionBar不影响Activity的布局内容,我们还可以设置ActionBar,将其设置为透明,并且让Activity是头部自动空出一个ActionBar的空间:


    官方文档:http://wear.techbrood.com/training/basics/actionbar/overlaying.html#EnableOverlay

    在应用程序里面,我们添加了一个背景:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        tools:context=".MainActivity" >
    
    	<ImageView android:layout_width="fill_parent"
    	    android:layout_height="fill_parent"
    	    android:background="@drawable/bg2"/>
    
    </RelativeLayout>
    
    然后自定义一个主题values/themes.xml,继承自Theme.Holo

    <?xml version="1.0" encoding="utf-8"?>
    <resources xmlns:android="http://schemas.android.com/apk/res/android">
        <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo">
            <item name="android:windowActionBarOverlay">true</item>
        </style>
    </resources>
    
    这样就可以实现ActionBar是透明效果:

    让其背景让出一个ActionBar的位置 ,在Activity布局文件中让其android:paddingTop="?android:attr/actionBarSize"

    然后查看效果:



  • 相关阅读:
    Python 虚拟环境(VirtualEnv)
    python 枚举
    Python 面向对象编程
    Python 使用模块
    Python 函数
    Python dict & set
    JAVA-工具类
    09-12 练习题
    JAVA-数组
    java-语句
  • 原文地址:https://www.cnblogs.com/raphael5200/p/5114778.html
Copyright © 2011-2022 走看看