左側にドローアブルのあるテキストが必要で、ユーザーが画像(テキストではなく画像のみ)をクリック/タッチしたときにコードを実行したいので、TextViewとImageViewでLinearLayoutを使用しました。クリック可能で、onClickイベントを起動します。XMLパーサーは、これを複合ドローアブルを備えたTextViewに置き換えることを提案します。これにより、同じものをはるかに少ないXML行で描画できます。私の質問は、「onClickイベントをドローアブルでのみ処理するように指定できますか?TextView自体ではなくTextView ? TextViewの独自の拡張機能を作成することを含むいくつかの解決策を見てきました、しかし、可能であれば、レイアウトリソース内でそれを実行できるようにすることにのみ関心があります。それ以外の場合は、次のXMLコードを保持します。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/home_feedback_title"
android:textColor="@android:color/primary_text_dark"
android:textStyle="bold"
android:paddingBottom="4dp"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/action_feedback"
android:clickable="true"
android:onClick="onClickFeedback"
android:contentDescription="@string/action_feedback_description"/>
</LinearLayout>