2012-04-01 11 views
0

右矢印の背景を設定しようとしています。これを押すと、矢印の周りの背景のみが表示されます(区切り文字まで)。Androidのリストアイテムのレイアウトを一覧表示する

イメージボタンでやろうとしましたが、このようにするとリストアイテムをクリックできません。

これは私のXMLアイテムリストのレイアウトです:

xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:paddingBottom="5dip" 
    android:paddingLeft="2dip" 
    android:paddingRight="2dip" 
    android:paddingTop="5dip" > 

    <ImageView 
     android:id="@+id/itemlist_checkedd" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:adjustViewBounds="true" 
     android:src="@drawable/ic_checkitem" /> 


    <ImageView 
     android:id="@+id/skinpreview" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:layout_toRightOf="@id/itemlist_checkedd" 
     android:scaleType="fitXY" /> 

    <ImageButton 
     android:id="@+id/skinEdit" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:adjustViewBounds="true" 
     android:paddingLeft="10dip" 
     android:background="@null" 
     android:src="@drawable/ic_go_edit" /> 

    <ImageView 
     android:id="@+id/separator" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerVertical="true" 
     android:layout_toLeftOf="@id/skinEdit" 
     android:layout_marginRight="5dip" 
     android:src="@drawable/separator"/> 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="2dip" 
     android:layout_marginRight="15dip" 
     android:layout_toRightOf="@id/skinpreview" 
     android:layout_toLeftOf="@id/separator" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

これは、それがどのように見えるかです:

enter image description here

任意の提案は?おかげさまで ただ、

答えて

1

このXMLで親ビューに背景色や画像を設定し

+0

感謝をあなたのImageViewのsrcを割り当てます。もう1つの質問は、「矢印押された」画像だけをどのように引き伸ばすことができますか?これはセパレータ画像までの領域全体に収まるでしょうか? –

+0

他に何か意味がある場合、あなたのコード内にイメージを宣言することができますarrowview(ImageView)findViewById(R.id.arrow)のarrow_pressed(大/小/青/ ;矢印の関数を使用してその画像のxmlプロパティで再生し、onClick()関数でそれを行います。 –

1

は、あなたがして、矢印の別の画像を作成する必要があります/解像度で描画可能

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
    android:state_pressed="true" 
    android:drawable="@drawable/arrow_pressed" /> 
    <item 
    android:state_pressed="false" 
    android:drawable="@drawable/arrow" /> 
</selector> 

を選択xmlファイルを作成します。あなたが必要とする強調表示された背景。当然の

その後、例えばXMLファイル(arrow_selector.xml)にあなたの答えのための

関連する問題