• 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"

    然后查看效果:



  • 相关阅读:
    自定义函数
    内置函数
    炸裂函数explode
    -bash:ls:command not found,执行命令总是报找不到
    函数
    C#的lock用法
    获取客户端Ip地址方法
    Grunt基础
    常用Sql
    HandleBars
  • 原文地址:https://www.cnblogs.com/raphael5200/p/5114778.html
Copyright © 2020-2023  润新知