1

画像でカスタムを作り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>

ここに画像の説明を入力してください

それは機能していますが、それをタッチしてカスタムリストビューに移動すると、壊れています。私はこの背景に問題があるかもしれないと思いますmain.xml

ここに画像の説明を入力してください

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>

他の属性を変更するのにうんざりしていて、機能していません。

4

1 に答える 1

1

置く代わりに

android:background="@drawable/gradient_body"

main.xmlのリストビューで、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" >
于 2012-10-26T15:45:28.313 に答える