[英]Drawer layout listView transparent background
I'm trying to set the background of the listview inside the drawer layout to be transparent like google's camera app. 我正在尝试将抽屉布局内的listview的背景设置为像Google的相机应用一样透明。
What happens is whenever I set the background of the listview to be transparent its items disappears 发生的事情是,每当我将listview的背景设置为透明时,其项就会消失
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main_drawer_layout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView
android:id="@+id/activity_main_navigation_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:background="@android:color/transparent"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
I tried to set it to a transparent image it didn't work either it doesn't work with any transparency added to the color of it's background. 我试图将其设置为透明图像,但它既不起作用,又或与背景颜色添加任何透明度的情况下均不起作用。
This works: 这有效:
android:background="#232321"
This doesn't 这不是
android:background="#fb232321"
Any idea how can I fix this problem 任何想法我该如何解决这个问题
Try using android:background="@color/transparent"
on DrawerLayout view and not on the listView. 尝试在DrawerLayout视图而不是listView上使用
android:background="@color/transparent"
。 Also, you can use background transparent on childView of your ListView 另外,您可以在ListView的childView上使用透明背景
So the I solved my problem by wrapping the listview with a Relativelayout it works with other layouts as well. 所以我通过用一个Relativelayout包装listview来解决我的问题,它也可以与其他布局一起使用。
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<FrameLayout
android:id="@+id/activity_main_frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/transparent"
android:focusableInTouchMode="true">
<ListView
android:id="@+id/activity_main_navigation_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:clickable="true"
android:divider="@android:color/transparent"
android:dividerHeight="1dp"
android:focusable="true" />
</RelativeLayout>
使用#00000000以获得黑色透明度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.