center only icons (not text also) horizontally and vertically on a button
android, xml
Solution
Use an ImageButton:
<ImageButton
android:id="@+id/sharepic"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="@drawable/round"
android:src="@android:drawable/ic_dialog_email"
/>
Problem
I have 3 buttons at the bottom of an app im creating, and I'm just trying to use some stock android icons instead of text or a combination of both. There is the `andoid:drawableStart / top / bottom / etc` commands but I just would like these icons to appear smack dab in the middle. There seems to be no easy solution for this? Here is what I am working with: ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/calm" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".PiktuurMain" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" > <Button android:id="@+id/takepic" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/round" /> <Button android:id="@+id/editpic" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_weight="1" android:background="@drawable/round" /> <Button android:id="@+id/sharepic" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/round" android:drawableStart="@android:drawable/ic_dialog_email" /> </LinearLayout> </RelativeLayout> ```