java - How do I adjust these images displayed on gridlayout? -


i've displayed on gridlayout 4 direction bottons trying make "game control panel" this:

enter image description here

the game made, trouble "game panel", that's looks small on big devices tablet:

enter image description here

how can make buttons displayed filling parent?, xml code this, i've made custom layout called square layout display game:

<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"  tools:context=".mainactivity" android:background="@drawable/background" android:padding="10dp">  </*packages*/squarelayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:id="@+id/square"     android:layout_alignparentleft="true"     android:layout_alignparentstart="true">      //gameview <//*packages*/squarelayout>   <framelayout     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:layout_below="@+id/afgergg"     android:id="@+id/framelayout"     android:layout_alignparentbottom="true">       <gridlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center">          <imagebutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:id="@+id/up"             android:layout_row="0"             android:layout_column="1"             android:longclickable="true"             android:background="@drawable/background"             android:src="@drawable/ic_arrow_up" />          <imagebutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:id="@+id/down"             android:layout_row="2"             android:layout_column="1"             android:background="@drawable/background"             android:src="@drawable/ic_arrow_down" />          <imagebutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:id="@+id/left"             android:layout_row="1"             android:layout_column="0"             android:background="@drawable/background"             android:src="@drawable/ic_arrow_left" />          <imagebutton             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:id="@+id/right"             android:layout_row="1"             android:layout_column="2"             android:background="@drawable/background"             android:clickable="true"             android:src="@drawable/ic_arrow_right" />         </gridlayout> </framelayout> 

you treat 3x3 grid 5 dummy views i.e replace grid layout with

<linearlayout  android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:orientation="vertical"     >     <linearlayout  android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:orientation="horizontal"         >         <view  android:layout_width="0dp"             android:layout_weight="1"             android:layout_height="wrap_content"/>         <imagebutton             android:layout_width="0dp"             android:layout_height="wrap_content"             android:id="@+id/up"             android:layout_weight="1"             android:longclickable="true"             android:adjustviewbounds="true"             android:background="@drawable/background"             android:src="@drawable/ic_arrow_up" />         <view  android:layout_width="0dp"             android:layout_weight="1"             android:layout_height="wrap_content"/>     </linearlayout>      <linearlayout  android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:orientation="horizontal"         >         <imagebutton             android:layout_width="0dp"             android:layout_height="wrap_content"             android:id="@+id/left"             android:layout_weight="1"             android:adjustviewbounds="true"             android:background="@drawable/background"             android:src="@drawable/ic_arrow_left" />         <view  android:layout_width="0dp"             android:layout_weight="1"             android:layout_height="wrap_content"/>         <imagebutton             android:layout_width="0dp"             android:layout_height="wrap_content"             android:id="@+id/right"             android:layout_weight="1"             android:background="@drawable/background"             android:clickable="true"             android:adjustviewbounds="true"             android:src="@drawable/ic_arrow_right" />     </linearlayout>      <linearlayout  android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:orientation="horizontal"         >         <view  android:layout_width="0dp"             android:layout_weight="1"             android:layout_height="wrap_content"/>         <imagebutton             android:layout_width="0dp"             android:layout_height="wrap_content"             android:id="@+id/down"             android:layout_weight="1"             android:adjustviewbounds="true"             android:background="@drawable/background"             android:src="@drawable/ic_arrow_down" />         <view  android:layout_width="0dp"             android:layout_weight="1"             android:layout_height="wrap_content"/>     </linearlayout> </linearlayout> 

alternately use table layout. note: might wanna add margins etc.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -