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

Android UI ActionBar功能-自动隐藏 Action Bar

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

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

<RelativeLayout xmlns:andro
    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:andro>
    <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo">
        <item name="android:windowActionBarOverlay">true</item>
    </style>
</resources>
这样就可以实现ActionBar是透明效果:

Android UI ActionBar功能-自动隐藏 Action Bar

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

Android UI ActionBar功能-自动隐藏 Action Bar

然后查看效果:

Android UI ActionBar功能-自动隐藏 Action Bar

相关文章:

  • 2021-09-15
  • 2021-12-30
  • 2021-06-20
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2021-10-31
  • 2021-10-05
猜你喜欢
  • 2021-12-16
  • 2021-06-27
  • 2021-12-10
  • 2021-08-28
  • 2021-06-15
  • 2021-12-29
  • 2021-09-22
相关资源
相似解决方案