I revised the answer to answer your revised question.
The drawableLeft
, drawableRight
, and drawableTop
button, as far as I can tell, control where the image is placed relative to the selector (a/k/a on/off) indicator. Top will place it above the indicator with left and right placing it to a specific side respectively. I do not believe you can remove the selector indicator as that would defeat the purpose of using a ToggleButton
.
I was able to center 2 drawable in 2 ToggleButtons
using the following layout. To center the images within the ToggleButton
I used drawableTop
so that the images appeared over the selection indicator. I then set both textOn
and textOff
to be an empty string. If you do not set this, then the default on/off text appears above the selector indicator and pushes the drawable to the side.
<LinearLayout
android:id="@+id/buttonContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ToggleButton
android:id="@+id/bSmenuTopItems"
android:layout_width="0"
android:layout_weight="1"
android:layout_height="75dp"
android:checked="false"
android:drawableTop="@drawable/flag"
android:textOn=""
android:textOff=""
android:layout_gravity="center"
android:textColor="#cecece" />
<ToggleButton
android:id="@+id/bSmenuTopItems2"
android:layout_width="0"
android:layout_height="75dp"
android:layout_weight="1"
android:checked="false"
android:textOn=""
android:textOff=""
android:drawableTop="@drawable/chaticon"
android:layout_gravity="center"
android:textColor="#cecece" />
</LinearLayout>
All you should have to do is adjust the height of the button to position your icon relative to the selector icon where you want it. My only other suggestion would be to control the size of the image you are using. If you can just adjust the dimensions of the image relative to the button, placing it with drawableTop should center it automatically.
LinearLayout
. But why would that affect what goes on inside thebutton
? – Underexpose