简体   繁体   English

Android ListView透明背景不起作用

[英]Android ListView transparent background not working

android:divider transparency is not working. android:divider透明度不起作用。 Setting a color (eg #BBF232) is working fine. 设置颜色(例如#BBF232)工作正常。 Using "@android:color/transparent" as listview background is working properly aswell. 使用“ @android:color / transparent”作为列表视图背景也可以正常工作。 Just when using it as divider nothing happens. 只是将其用作分隔线时,什么也不会发生。 Any Ideas ? 有任何想法吗 ?

My XML ListView Code: 我的XML ListView代码:

    <ListView
    android:id="@+id/listView1"
    android:background="#FFFFFF"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/imageButton2"
    android:layout_below="@+id/imageButton1"
    tools:listitem="@android:layout/simple_list_item_2" 
    android:layout_alignParentRight="true"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_marginTop="15dp"
    android:divider="@android:color/transparent"
    android:dividerHeight="10dp">

Inside listview use this code: 在listview内部使用此代码:

        android:background="@android:color/transparent"
        android:cacheColorHint="@android:color/transparent"

If you are using cardview then use the following code: 如果您使用的是cardview,请使用以下代码:

app:cardBackgroundColor="@android:color/transparent"

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

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