【发布时间】:2016-04-19 15:00:02
【问题描述】:
我正在尝试使我的 AppCompatActivity 的操作栏透明。我正在寻找like this(来自this app)的东西。
我试过这样做:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
但它唯一能做的就是让视图隐藏在操作栏后面。
我该怎么做才能使文本和抽屉式导航按钮成为其上唯一可见的东西?
编辑: 这是我的 xml 布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="my.package.name"
android:id="@+id/relLayout">
<!-- My views are here -->
</RelativeLayout>
</ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
【问题讨论】:
-
你试过设置ActionBar的背景色吗?请显示您的 xml 布局。
-
@jonas.koeritz 我不确定如何使颜色不透明。我在xml布局中编辑。
-
@RuwankaMadhushan 你做到了!我将它与我之前的代码结合起来并使用颜色#00ffffff,它按预期完成了所有操作。谢谢!
-
尝试像 #00000000 这样的 ARGB 值以获得完全透明。
标签: android android-actionbar android-appcompat