[英]Android : Transparent bar under action bar
How can i add transparent bar under action bar like this : 我如何在操作栏下面添加透明栏:
I'm beginner please advice 我是初学者请指教
UPDATE 更新
It's my code, but transparent bar did not appeared on layout, because map fragment is over transparent 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>
AND 和
<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>
Here is a quick example: 这是一个简单的示例:
Code for activity_main.xml 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>
I have made the fragment overlay by using android:elevation
, you can also use android:translationZ
, it is available in API version 21. I un aware of any other methods of achieving this kind of overlay on fragments. 我已经使用
android:elevation
制作了片段叠加层,也可以使用android:translationZ
,它在API版本21中可用。我不知道有任何其他方法可以在片段上实现这种叠加。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.