0

私はテキストビューを使用しています:

 <TextView
     android:id="@+id/textView_setup_menu_msa"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignLeft="@+id/textView_member_menu_msa"
     android:layout_below="@+id/textView_event_menu_msa"
     android:layout_marginTop="38dp"
     android:text="@string/string_setup_menu_msa"
     android:textColor="#000000"
     android:textSize="8pt" 
     android:onClick="onCLick"
     android:clickable="true"
     android:background="@drawable/textview_selector"/>

リストビューのようなテキストビューをクリックしたときにセレクター画像を設定したいのですが、次のようにしました: res/drawable/textview_selector.xmlで、

   <selector xmlns:android="http://schemas.android.com/apk/res/android" >
      <item android:state_enabled="true"
         android:state_pressed="true" 
         android:drawable="@drawable/selectioncell" />
      <item 
         android:state_enabled="true"
         android:state_focused="true" 
         android:drawable="@drawable/selectioncell" />

      <item android:state_enabled="true"
         android:state_selected="true" 
         android:drawable= "@drawable/selectioncell" /> 
   </selector>

ここで「selectioncell」はイメージです。しかし、テキストビューを選択しているときに画像の適切なサイズが得られません。テキストビューだけでなくセル全体を選択したい。リストビューのようにする方法はありますか?

4

1 に答える 1

0

textview_selector.xml が ImageView ではなく TextView に設定されている場合は、これを行うことはできません。そのセレクターを ImageView に設定し、TextView onClickListener で yourimageview.performClick() を呼び出します。役に立つかもしれません。

于 2013-02-17T10:14:57.267 に答える