簡體   English   中英

抽屜布局列表查看透明背景

[英]Drawer layout listView transparent background

我正在嘗試將抽屜布局內的listview的背景設置為像Google的相機應用一樣透明。

發生的事情是,每當我將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>

我試圖將其設置為透明圖像,但它既不起作用,又或與背景顏色添加任何透明度的情況下均不起作用。

這有效:

        android:background="#232321"

這不是

        android:background="#fb232321"

任何想法我該如何解決這個問題

嘗試在DrawerLayout視圖而不是listView上使用android:background="@color/transparent" 另外,您可以在ListView的childView上使用透明背景

所以我通過用一個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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM