这是我的自定义布局,我将其设置为我的列表视图标题,并且在单击时有一些功能要做,但只有当布局中的视图可点击时,休息时才会响应
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/Gray"
android:clickable="true">
<RelativeLayout
android:id="@+id/my_custom_layout"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center_vertical">
<RelativeLayout
android:id="@+id/customPhotoLayout"
style="@style/listItemMarginStyle"
android:layout_width="@dimen/custom_circle_width"
android:layout_height="@dimen/custom_circle_height">
<ImageView
android:id="@+id/custom_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/custom_image_description" />
<TextView
android:id="@+id/custom_first_letter"
style="@style/customInitialStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"/>
</RelativeLayout>
<TextView
android:id="@+id/my_custom_name"
style="@style/myProfileStyle"
android:layout_marginStart="@dimen/custom_list_item_padding_horizontal"
android:layout_marginTop="@dimen/custom_list_item_padding_vertical"
android:layout_toEndOf="@+id/customPhotoLayout"
android:text="@string/default_my_custom_name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/custom_list_name"
android:textSize="@dimen/custom_text_size" />
<TextView
android:id="@+id/my_custom_profile"
style="@style/mycustomStyle"
android:layout_below="@+id/my_custom_name"
android:layout_marginBottom="@dimen/custom_list_item_padding_vertical"
android:layout_marginStart="@dimen/custom_list_item_padding_horizontal"
android:layout_toEndOf="@+id/customPhotoLayout"
android:text="@string/my_custom_profile"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black"
android:textSize="20sp" />
</RelativeLayout>
只有这个视图可以点击而不是上面的部分
<View
android:id="@+id/space"
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="@color/separator_color" />
</RelativeLayout>