gpt4 book ai didi

android - Expandablelistview 展开时背景变黑

转载 作者:太空宇宙 更新时间:2023-11-03 12:40:11 26 4
gpt4 key购买 nike

我在 Android 2.3.5(可能还有更早的 Android 版本)上遇到这个问题

当我的 expnadablelistview 折叠时,背景会正确显示。一旦一组行展开,它的背景就会变黑。

这是 ListView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
>

<TextView
android:id="@+id/ExpandableListText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor = "#490600"
android:paddingRight = "25sp"
android:paddingLeft = "25sp"
/>

<ExpandableListView
android:id="@+id/ExpandableListView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:divider="#000000"
android:dividerHeight="1sp"
android:childDivider="#000000"
android:headerDividersEnabled="true"
android:footerDividersEnabled="true"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
android:drawSelectorOnTop="true"
/>
</LinearLayout>

这是组行的 XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"

>

<TextView
android:id="@+id/TextViewGroup"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="50sp"
android:gravity="center_vertical"
android:textColor = "#490600"
android:paddingTop="7dip"
android:paddingBottom="7dip"
><!-- -->
</TextView>

</LinearLayout>

这是 child_row XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"

>
<!-- android:background="#666666" -->
<!-- -->
<TextView
android:id="@+id/TextViewChild01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30sp"
android:textColor = "#000000"
>
</TextView>

<TextView
android:id="@+id/TextViewChild02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10sp"
android:textColor = "#000000"
>
</TextView>

<TextView
android:id="@+id/TextViewChild03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10sp"
android:textColor = "#000000"
>
</TextView>

</LinearLayout>

非常感谢任何帮助

最佳答案

自定义您的 ExpandableListView 类,然后 -

package com.test
//....................

View getView(.....) {
View v = super.getView(....);

//........
//change it your color or or set the text you want.
return(v);
}

然后将其设置到您的布局中 -

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg"
>

<TextView
android:id="@+id/ExpandableListText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor = "#490600"
android:paddingRight = "25sp"
android:paddingLeft = "25sp"
/>

<com.test.ExpandableListView
android:id="@+id/ExpandableListView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:divider="#000000"
android:dividerHeight="1sp"
android:childDivider="#000000"
android:headerDividersEnabled="true"
android:footerDividersEnabled="true"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
android:drawSelectorOnTop="true"
/>

关于android - Expandablelistview 展开时背景变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9860465/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com