J'ai un problème très inhabituel; J'ai quelques ToggleButtons à l'intérieur d'une disposition linéaire empilée horizontalement. Le texte à l'intérieur (texton, textOff) des boutons n'est pas centrage, et après avoir joué un peu avec paddingLeft, je trouve que 15% de chaque bouton sur le côté droit est quelque chose d'une « zone morte », ce qui signifie le texte est l'emballage quand il frappe - cela expliquerait pourquoi il ne se centre pas correctement.texte Android à l'intérieur du centre ToggleButton wont
Voici le XML:
<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 ><
J'ai essayé le réglage de la gravité dans la mise en page et les boutons à center_horizontal ainsi .. De toute évidence, il n'a pas aidé.
Des idées?
et cela aussi chaque ToggleButton: android: gravité = « center » –