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>
You can use MaterialButton
. It has more advantages than something else. like the ripple effect, theme, icon tint, shape appearance, and so on.
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="0dp"
app:icon="@drawable/ic_baseline_sports_soccer_24"
app:iconPadding="0dp" />
<androidx.appcompat.widget.AppCompatImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_sports_soccer_24" />
Also, you should set android:padding="Xdp"
to get suit width.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With