2012-02-25 15 views
1

私はtextviewとチェックボックスでカスタムリストビューを持っています。私は、その高さを見ることのTextViewするBG色を追加Androidのtextviewの高さとチェックボックスのリストビュー

enter image description here

<TextView android:id="@+id/rowTextView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:background="#222222"/> 

<CheckBox 
    android:id="@+id/CheckBox01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:focusable="false" 
    > 
</CheckBox> 

結果:これはXMLファイルです。問題は、テキストボックス(黒いスペース)の周りをクリックするとチェックボックスがチェックされる(un)ことになります。テキストビューをクリックすると、チェックボックスは状態のままです。私はTextViewの(40dip)の高さを拡張しようとしましたが、それはこのの結果:

enter image description here私は、チェックボックスの高さまでのTextViewの高さを設定するにはどうすればよい

答えて

1

異なる線形レイアウトでtextViewとCheckBoxの両方を保持してください。これをチェックすると、問題が解決する可能性があります。

1

ボタンにカスタムスタイルを設定し、デフォルトの値に戻します。 ボタンの余白を設定できます。 ボタンの高さに固定のDP値を設定できます。

スタイル= "アンドロイド:?のattr/buttonStyleSmall" ... />

2

これがソリューションです。完璧ではありませんが、機能しています。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

    <TextView android:id="@+id/rowTextView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:paddingTop="15dip" 
    android:paddingBottom="15dip" 
    android:background="#222222"> 
    </TextView> 

    <CheckBox android:id="@+id/CheckBox01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" android:layout_marginRight="6sp" 
    android:focusable="false"> 
    </CheckBox> 

</RelativeLayout> 
関連する問題