I'm trying to set the background of the listview inside the drawer layout to be transparent like google's camera app.
What happens is whenever I set the background of the listview to be transparent its items disappears
<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. Also, you can use background transparent on childView of your ListView
So the I solved my problem by wrapping the listview with a Relativelayout it works with other layouts as well.
<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以获得黑色透明度
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.