I need to put some ImageButton with equal space in layout(something like the picture I attached). I checked a lot of similar posts like:
Android: How to make all elements inside LinearLayout same size?
give equal space between ImageViews
What is android:weightSum in android, and how does it work?
However they didn't help me. Using margin and padding didn't solve my problem, because I want to have equal space around ImageButton. It is important for me to keep the space equal in any device. Also I want to set size to my ImageButton. It's a rounded image so the height and width of image should be equal . When I use weightsum, I can't set arbitrary width as layout_width for ImageButton.
Thanks for helping me.
P.S. This is not duplicate post. In the first link which i brought, it is not possible to set equal space. It just put objects next to each other.
This is a layout with 2 ImageButton with arbitrary size:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="info.androidhive.materialdesign.activity.HomeFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/background_home">
<ImageButton
android:layout_width="@dimen/log_guid_image_height"
android:layout_height="@dimen/log_guid_image_height"
android:onClick="onLastClick"
android:id="@+id/btn_menu_last"
android:background="@drawable/menu_last" />
<ImageButton
android:layout_width="@dimen/log_guid_image_height"
android:layout_height="@dimen/log_guid_image_height"
android:onClick="onAddClick"
android:id="@+id/btn_menu_add_records"
android:background="@drawable/menu_add_records" />
</LinearLayout>
I added android:layout_weight="1" to each ImageButton, and set android:layout_width="0px" and it gave me this:
The problem is that how I can add equal space around ImageButton and gave arbitrary size to them!!!