Android CustomListView背景问题
我用图像制作了一个自定义的Android CustomListView背景问题,android,xml,listview,layout,background,Android,Xml,Listview,Layout,Background,我用图像制作了一个自定义的列表视图。我的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:padd
列表视图
。我的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>
<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中,将其添加到you 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:background="@drawable/gradient_body"
在main.xml中的listview中,将其添加到you 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" >
谢谢@Irfan。。它的工作方式,但没有产生“单击”效果(默认情况下,单击橙色效果),只需在列表视图中使用android:drawSelectorOnTop=“true”,它将为您提供所需的效果。。这很有效。。谢谢@Irfan。。但如果显示所需效果,则文本是可见的。。有什么把戏吗?好吧,我不明白你的意思。您是否希望列表项的文本在单击它时立即消失?事实上恰恰相反。如果我使用你的代码,文本将消失。如何保持文字不消失?谢谢@Irfan。。它的工作方式,但没有产生“单击”效果(默认情况下,单击橙色效果),只需在列表视图中使用android:drawSelectorOnTop=“true”,它将为您提供所需的效果。。这很有效。。谢谢@Irfan。。但如果显示所需效果,则文本是可见的。。有什么把戏吗?好吧,我不明白你的意思。您是否希望列表项的文本在单击它时立即消失?事实上恰恰相反。如果我使用你的代码,文本将消失。如何保持文字不消失?