繁体   English   中英

Android:操作栏下的透明栏

[英]Android : Transparent bar under action bar

我如何在操作栏下面添加透明栏:
我是初学者请指教

在此处输入图片说明

更新
这是我的代码,但是布局上没有出现透明条,因为地图片段在透明条上,

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

    <include 
        layout="@layout/notification_bar"
        android:id="@+id/notification_bar"/>

    <fragment
        android:id="@+id/map_fragment"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/bottom_menu"
        class="com.android.fragment.MapFragment"
        android:visibility="invisible" />
</RelativeLayout>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="#99000000"
    android:layout_width="fill_parent"
    android:layout_height="90dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:id="@+id/notification_bar" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="39dp"
        android:layout_marginTop="37dp" >

    </LinearLayout>

</LinearLayout>

这是一个简单的示例:

屏幕截图

activity_main.xml的代码

<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"
    tools:context="com.example.testdesignapp.MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="10dp"
        android:alpha="0.5"
        android:background="#000"
        android:elevation="1dp"
        android:gravity="top"
        android:orientation="horizontal"
        android:padding="5dp" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Here is some random overlay text example"
            android:textColor="#fff" />

    </LinearLayout>

    <fragment
        android:id="@+id/map_fragment"
        android:name="com.example.testdesignapp.FooFragment"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:visibility="invisible" />

</RelativeLayout>

我已经使用android:elevation制作了片段叠加层,也可以使用android:translationZ ,它在API版本21中可用。我不知道有任何其他方法可以在片段上实现这种叠加。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM