gpt4 book ai didi

android - 快图如何做一个半透明的actionbar?

转载 作者:太空狗 更新时间:2023-10-29 12:43:29 28 4
gpt4 key购买 nike

在 Android KitKat 中有用于

的选项
    <item name="android:actionBarStyle">@style/TranslucentActionBar</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>

如何让应用像 QuickPic 一样执行,滚动时内容开始滚动到操作栏下方?

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clipToPadding="false"
tools:context="com.jhdev.red.MainActivity"
tools:ignore="MergeRootFrame" >

<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="@integer/num_columns"
android:clipToPadding="false"/>

</FrameLayout>

最佳答案

仅适用于 Android 3.0 及更高版本

如果您的 minSdkVersion 设置为 11 或更高,您的自定义主题应使用 Theme.Holo 主题(或其后代之一)作为您的父主题。例如:

<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
</style>
</resources>

适用于 Android 2.1 及更高版本

如果您的应用使用支持库来兼容运行低于 Android 3.0 版本的设备,您的自定义主题应该使用 Theme.AppCompat 主题(或其后代之一)作为您的父主题。例如:

<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.AppCompat">
<item name="android:windowActionBarOverlay">true</item>

<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>
</style>
</resources>

指定布局上边距

当操作栏处于覆盖模式时,它可能会遮盖一些本应保持可见的布局。为确保此类项目始终保持在操作栏下方,请使用 actionBarSize 指定的高度向 View 顶部添加边距或填充。例如:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?android:attr/actionBarSize">
...
</RelativeLayout>

如果您使用操作栏的支持库,则需要删除 android: 前缀。例如:

<!-- Support library compatibility -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize">
...
</RelativeLayout>

在这种情况下,不带前缀的 ?attr/actionBarSize 值适用于所有版本,包括 Android 3.0 及更高版本。

Details

另请查看此 link寻求更多帮助。

关于android - 快图如何做一个半透明的actionbar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21749324/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com