【问题标题】:android:cacheColorHint="#00000000" don't work for <ExpandableListViewandroid:cacheColorHint="#00000000" 不适用于 <ExpandableListView
【发布时间】:2023-04-01 05:38:01
【问题描述】:

我正在使用 ExpandableListView,当展开和滚动时,滚动完成后它会变黑一秒钟。我使用了“android:cacheColorHint="#00000000" 但它似乎不适用于可扩展的列表视图。代码是:

    <ExpandableListView android:id="@+id/android:list"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:layout_marginBottom="55dp" android:divider="@color/color_negro"
        android:listSelector="@android:color/transparent"
        android:cacheColorHint="#00000000" android:childDivider="@color/color_negro"
        android:descendantFocusability="afterDescendants" android:background="@null">
    </ExpandableListView>

并为绘制每个孩子:

            public View newChildView(boolean isLastChild, ViewGroup parent) {
                if(layoutInflater == null){
                    layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                }
                return layoutInflater.inflate(R.layout.row_personas, null, false);
            }

row_personas.xml 的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:background="@layout/custom_text_view_apellido"
android:layout_marginLeft="20dp" android:layout_marginRight="15dp"
>

<TextView android:id="@+id/rowApellido" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="@color/color_negro"
android:textSize="14sp" android:paddingLeft="10dp"
android:paddingTop="0dp" android:paddingRight="4dp"
android:paddingBottom="5dp" android:typeface="sans"
android:maxLength="20" >
</TextView>

<TextView android:id="@+id/rowNombres" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:textSize="14sp"
android:textColor="@color/color_negro" android:paddingBottom="5dp"
android:layout_marginRight="5dp" android:maxLength="20"
android:singleLine="true" android:typeface="sans" android:paddingTop="0dp" >
</TextView>

</LinearLayout>

<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:layout_marginLeft="20dp" android:layout_marginRight="15dp">

<ImageView android:id="@+id/photo" android:layout_height="34dp"
android:layout_width="41dp" android:layout_marginTop="2dp"
android:layout_marginRight="2dp" />

<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">

<TextView android:id="@+id/rowDatoRelevante"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textStyle="bold" android:textColor="@color/color_gris_oscuro"
android:textSize="12sp" android:paddingLeft="15dp"
android:paddingTop="1dp" android:paddingBottom="1dp"
android:background="@layout/custom_text_view_categoria"
android:gravity="left" android:layout_marginRight="25dp"
android:singleLine="true">
</TextView>

<TextView android:id="@+id/rowDatoRelevante2"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textStyle="italic" android:textColor="@color/color_gris_oscuro"
android:textSize="12sp" android:paddingLeft="15dp"
android:background="@layout/custom_text_view_categoria_desc"
android:gravity="left" android:layout_marginRight="55dp"
android:singleLine="true">
</TextView>
</LinearLayout>
</LinearLayout>

</LinearLayout>

如果有人可以帮助我...谢谢!!!!!!

【问题讨论】:

    标签: android background scroll expandablelistview


    【解决方案1】:

    我的问题解决了!!!我用这种方式更改了 ExpandableListView 的声明:

    <ExpandableListView android:id="@+id/android:list"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_marginBottom="55dp"
    android:scrollbarAlwaysDrawVerticalTrack="true" android:divider="@android:color/black"
    android:childDivider="@android:color/transparent"
    android:listSelector="@android:color/transparent"
    android:cacheColorHint="@android:color/transparent"
    android:background="@android:color/transparent">
    </ExpandableListView>
    

    我认为问题在于将黑色分配给“android:childDivider”。我希望能帮助别人!

    【讨论】:

      【解决方案2】:

      我可以通过绘制 9 补丁 png 并将其设置为 childDivider 来修复类似的错误。我的 9 补丁 png 高两个像素:第一行设置为所需的分隔线颜色,第二行 - 可拉伸 - 透明。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-25
        • 1970-01-01
        • 2014-08-30
        • 2015-05-08
        • 2016-11-23
        • 1970-01-01
        • 2015-03-20
        相关资源
        最近更新 更多