2011-06-24 8 views
2

私は非常に珍しい問題があります。私は、水平に積まれた線形レイアウトの中にいくつかのToggleButtonを持っています。ボタンの内側のテキスト(textOn、textOff)はセンタリングされていないので、paddingLeftで少し再生した後、右側の各ボタンの15%が「デッドエリア」のものであることがわかりました。それがヒットするときにラッピングしている - これは、なぜそれが適切にセンタリングしていないのかを説明します。ToggleButtonのAndroidのテキストが中央にない

がここにXMLです:私もcenter_horizo​​ntalするレイアウトやボタンで重力を設定しようとしました

 <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content">   
     <LinearLayout 
      android:id="@+id/buttons" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:padding="6dip" 
      android:weightSum="1.5" 
      android:background="#0094d2" 
      android:orientation="horizontal"> 
      <ToggleButton 
       android:id="@+id/button1" 
       android:layout_weight=".5" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textColor="@color/off_white" 
       android:textStyle="bold" 
       android:textOn="Button On" 
       android:textOff="Button Off" 
       android:background="@drawable/toggle_states"/> 
      <ToggleButton 
       android:id="@+id/button2" 
       android:layout_weight=".5" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textColor="@color/off_white" 
       android:textStyle="bold" 
       android:textOn="Button On" 
       android:textOff="Button Off" 
       android:background="@drawable/toggle_states"/> 
      <ToggleButton 
       android:id="@+id/button3" 
       android:layout_weight=".5" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:textColor="@color/off_white" 
       android:textStyle="bold" 
       android:textOn="Button On" 
       android:textOff="Button Off" 
       android:background="@drawable/toggle_states"/>     
     </LinearLayout> 
     <View android:background="#999999" android:layout_height="1dip" android:id="@+id/divider" android:layout_below="@+id/buttons" android:layout_width="fill_parent"/> 
      <ListView 
       android:id="@+id/listview" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:focusable="true" 
       android:divider="#cccccc" 
       android:dividerHeight="1dip"      
       android:layout_below="@+id/divider" 
       android:fadingEdge="none"/> 
    </RelativeLayout> 

Link to Image, I'm too new so I can't add images yet ><

...明らかに、それは助けにはなりませんでした。

アイデア?

+0

、これはあまりにもそれぞれのトグルボタン: アンドロイド:重力=「センター」 –

答えて

1

私は日食に貼り付け/コピーされました:

enter image description here

私はあなたのドローアブルを持っていけない、彼らのようにカントを見たが、私はそれがあなたの問題だと思います。このリンクを見ていない場合は、あなたのボタンの9枚のパッチのグラフィックスを使用している: http://developer.android.com/guide/developing/tools/draw9patch.html

+0

私は9枚のパッチのグラフィックスを使用していますし、あなたがしていますそうです...これには関係があります。私は月曜日に自分のボタンを掲示し、自分でこの問題を回避できるかどうかを見て回ります。 – Vorathe

+0

トグルボタンをここにアップロードしました:[リンク](http://i.imgur.com/iudpn.png) 上位2つは9個のファイル、下2は通常のファイルです。それは私が9patch'dそれらの方法とは何かを持っている必要があります。 – Vorathe

+0

クール、私は今日かなり忙しいので、私は試してみて、後であなたのためにそれらを見て、あなたに戻ってきます。 – Kenny

関連する問題