java - Best way to make a 3x3 image button layout for android studio -
i looking make android version (i started learning how use android studio). have difficulties layout. want make 3x3 image button on main activity don't know how fix sizes fit screens. in xcode (ios), drag , resize , set constraints i'm having trouble doing in android studio.
can tell me how it? or @ least redirect me post or video me?
you can use gridview or can implement using linearlayout this. check out xml layout work you.
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#d3d3d3" tools:context=".ui.mainactivity"> <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorprimary" /> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightsum="3"> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:layout_margin="2.5dp" android:orientation="horizontal" android:weightsum="3"> <linearlayout android:id="@+id/l1" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5dp" android:background="@android:color/white" android:orientation="vertical" > <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="fitcenter" android:src="@drawable/hath_back_icon" /> </linearlayout> <linearlayout android:id="@+id/l2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@android:color/white" android:layout_margin="5dp" android:orientation="vertical" > <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="fitcenter" android:src="@drawable/hath_back_icon" /> </linearlayout> <linearlayout android:id="@+id/l3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5dp" android:background="@android:color/white" android:orientation="vertical" > <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="fitcenter" android:src="@drawable/hath_back_icon" /> </linearlayout> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:layout_margin="2.5dp" android:weightsum="3"> <linearlayout android:id="@+id/l4" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5dp" android:background="@android:color/white" android:orientation="vertical" > <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="fitcenter" android:src="@drawable/hath_back_icon" /> </linearlayout> <linearlayout android:id="@+id/l5" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@android:color/white" android:layout_margin="5dp" android:orientation="vertical" > <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="fitcenter" android:src="@drawable/hath_back_icon" /> </linearlayout> <linearlayout android:id="@+id/l6" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5dp" android:background="@android:color/white" android:orientation="vertical" > <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="fitcenter" android:src="@drawable/hath_back_icon" /> </linearlayout> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:layout_margin="2.5dp" android:weightsum="3"> <linearlayout android:id="@+id/l7" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5dp" android:background="@android:color/white" android:orientation="vertical" > <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="fitcenter" android:src="@drawable/hath_back_icon" /> </linearlayout> <linearlayout android:id="@+id/l8" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@android:color/white" android:layout_margin="5dp" android:orientation="vertical" > <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="fitcenter" android:src="@drawable/hath_back_icon" /> </linearlayout> <linearlayout android:id="@+id/l9" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:layout_margin="5dp" android:background="@android:color/white" android:orientation="vertical" > <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:scaletype="fitcenter" android:src="@drawable/hath_back_icon" /> </linearlayout> </linearlayout> </linearlayout>
Comments
Post a Comment