2011-01-13 12 views
2

私は背景として9パッチイメージを持つカスタムラジオボタンを持っています。私は背景を決定するためにセレクタを使用します。 私はまた、画像の背景を置きたいテキストをいくつか持っていますが、テキストはボタンの横に並んでいます。カスタムRadioButtonイメージが空白を埋めていない

このRADIOGROUP

<LinearLayout 
    android:id="@+id/segmented" 
    android:layout_width="fill_parent" 
    android:layout_height="50sp" 
    android:gravity="center" 
    android:layout_below="@+id/header"> 
    <RadioGroup android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:id="@+id/group1" 
     android:gravity="center"> 
     <RadioButton 
      android:checked="false" 
      android:layout_width="90sp" 
      android:id="@+id/rbVerzekeringen" 
      android:text="Verzekeringen" 
      android:textSize="10sp" 
      android:button="@drawable/checkbox_theme" /> 
     <RadioButton 
      android:checked="false" 
      android:layout_width="90sp" 
      android:id="@+id/rbPersoonlijk" 
      android:text="Persoonlijk" 
      android:textSize="10sp" 
      android:button="@drawable/checkbox_theme" /> 
     <RadioButton 
      android:checked="false" 
      android:layout_width="90sp" 
      android:id="@+id/rbNotities" 
      android:text="Notities" 
      android:textSize="10sp" 
      android:button="@drawable/checkbox_theme" /> 
    </RadioGroup> 
</LinearLayout> 

これはセレクタです:

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

そして、これはそれのようlookesものです:あなたは私を把握することができたよう

alt text

3つの大きなボタンの上にテキストが表示されます。

どうすればいいですか?

EDIT:

Iは、ボタンの代わりにバックグラウンドでセレクタを設定し、nullにボタンを設定します。

コードは次のようになります。

<LinearLayout 
    android:id="@+id/segmented" 
    android:layout_width="fill_parent" 
    android:layout_height="50sp" 
    android:gravity="center" 
    android:layout_below="@+id/header"> 
    <RadioGroup android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:id="@+id/group1" 
     android:gravity="center"> 
     <RadioButton 
      android:checked="false" 
      android:layout_width="100sp" 
      android:layout_height="40sp" 
      android:id="@+id/rbVerzekeringen" 
      android:text="Verzekeringen" 
      android:textSize="13sp" 
      android:orientation="vertical" 
      android:background="@drawable/checkbox_theme" 
      android:button="@null" 
      android:gravity="center"/> 
     <RadioButton 
      android:checked="false" 
      android:layout_width="100sp" 
      android:layout_height="35sp" 
      android:id="@+id/rbPersoonlijk" 
      android:text="Persoonlijk" 
      android:textSize="35sp" 
      android:background="@drawable/checkbox_theme" 
      android:button="@null" 
      android:gravity="center"/> 
     <RadioButton 
      android:checked="false" 
      android:layout_width="100sp" 
      android:layout_height="30sp" 
      android:id="@+id/rbNotities" 
      android:text="Notities" 
      android:textSize="13sp" 
      android:background="@drawable/checkbox_theme" 
      android:button="@null" 
      android:gravity="center"/> 
    </RadioGroup> 
</LinearLayout> 

しかし、私はボタンを大きくしたり小さくしたりする際に、今それのテキストがちょうど第二は35SPで、第1の画像の高さは40spである(このように消え、最後のものは30spです)。 height of the first image is 40sp, the second is 35sp and the last one is 30sp

テキストをカットせずに背景イメージを小さくするにはどうすればよいですか?

+0

私は自分の答えを – bigstones

答えて

6

あなたはボタンの代わりにアンドロイド:背景としてドロアブルを設定しようとしましたか?

hereを参照してください。


EDIT:

私はよく分からないが、私はそれが9パッチのコンテンツ領域(下と右のエッジライン)に依存だと思う、Androidはそれに基づいてパディングを設定し、9パッチの場合背景として設定されます。コンテンツ領域は画像とともに伸びます。

+0

編集しました。私はちょっと違った9パッチのイメージを作りました。ご協力いただきありがとうございます! – Galip

関連する問題