gpt4 book ai didi

android - CustomListView后台问题

转载 作者:行者123 更新时间:2023-11-30 03:57:42 25 4
gpt4 key购买 nike

我制作了一个带有图像的自定义 Listview。我的 items.xml 是这样的:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip"
android:soundEffectsEnabled="true"
>

<ImageView
android:layout_width="50dip"
android:layout_height="50dip"
android:id="@+id/imgViewLogo"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:scaleType="center">
</ImageView>

<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/txtViewTitle"
android:layout_toRightOf="@+id/imgViewLogo"
android:layout_marginLeft="2dip"
android:textColor="#000000">
</TextView>

<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/txtViewDescription"
android:layout_toRightOf="@+id/imgViewLogo"
android:layout_below="@+id/txtViewTitle"
android:layout_marginLeft="2dip"

android:textColor="#000000">
</TextView>

</RelativeLayout>

enter image description here

这是有效的,当我触摸它并将它移动到我的自定义 ListView 时,它坏了。我觉得这个后台main.xml可能有问题:

enter image description here

我的main.xml是这样的:

<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/gradient_body"
android:focusable="true"
>
<ListView
android:id="@+id/listView1"
android:background="@drawable/gradient_body"
android:focusable="true"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:divider="#c0bbbb"
android:dividerHeight="1dp"
></ListView>
</LinearLayout>

我厌倦了更改其他属性,但它不起作用。

最佳答案

而不是放置

android:background="@drawable/gradient_body"

在 main.xml 的 listview 中将它添加到 items.xml 的 relativeLayout 中,就像这样

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dip"
android:background="@drawable/gradient_body"
android:soundEffectsEnabled="true" >

关于android - CustomListView后台问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13089666/

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