java - Arranging buttons into diamond shape in android xml -


i create a screen 4 buttons, each in shape of diamond (like square turned 45 degrees side) , 4 arranged larger diamond.

i've searched around here on , managed create xml file sort of hints @ want achieve:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/white" android:orientation="vertical" android:visibility="visible">   <textview     android:id="@+id/scorecount"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="center_horizontal"     android:text="large text"     android:textappearance="?android:attr/textappearancelarge">  </textview>   <relativelayout     android:layout_width="match_parent"     android:layout_height="match_parent"      android:adjustviewbounds="true"     android:layout_weight="1.0" >       <button         android:id="@+id/topleftouter"         android:layout_centerinparent="true"         android:layout_width="60dp"         android:layout_height = "60dp"         android:background="@color/blue"         android:clickable="true"         android:visibility="visible"         android:adjustviewbounds="true"         android:rotation="45" >       </button>    </relativelayout>   <linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_weight="1.0"     android:clickable="true">      <relativelayout         android:layout_width="match_parent"         android:layout_height="match_parent"          android:adjustviewbounds="true"         android:layout_weight="1.0" >      <button         android:id="@+id/bottomleftouter"         android:layout_centerinparent="true"         android:layout_width="60dp"         android:layout_height = "60dp"         android:background="@color/yellow"         android:clickable="true"         android:visibility="visible"         android:adjustviewbounds="true"         android:rotation="45" >       </button>      </relativelayout>      <relativelayout         android:layout_width="match_parent"         android:layout_height="match_parent"          android:adjustviewbounds="true"         android:layout_weight="1.0" >          <button             android:id="@+id/bottomrightouter"             android:layout_centerinparent="true"             android:layout_width="60dp"             android:layout_height = "60dp"             android:background="@color/red"             android:clickable="true"             android:visibility="visible"             android:adjustviewbounds="true"             android:rotation="45" >           </button>      </relativelayout>  </linearlayout>  <linearlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_weight="1.0"     android:clickable="true">      <relativelayout         android:layout_width="match_parent"         android:layout_height="match_parent"          android:adjustviewbounds="true"         android:layout_weight="1.0" >          <button             android:id="@+id/toprightouter"             android:layout_centerinparent="true"             android:layout_width="60dp"             android:layout_height = "60dp"             android:background="@color/chartreuse"             android:clickable="true"             android:visibility="visible"             android:adjustviewbounds="true"             android:rotation="45" >           </button>      </relativelayout>  </linearlayout> 

this result:

this result

but more along lines of this:

enter image description here

how should go getting there?

i think you're looking this:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#fff" android:orientation="vertical" android:visibility="visible">   <textview     android:id="@+id/scorecount"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="center_horizontal"     android:text="large text"     android:textappearance="?android:attr/textappearancelarge"/>     <button     android:id="@+id/bottomrightouter"     android:layout_width="90dp"     android:layout_height = "90dp"     android:background="#ff0000"     android:clickable="true"     android:visibility="visible"     android:adjustviewbounds="true"     android:rotation="45"     android:layout_marginleft="218dp"     android:layout_marginstart="218dp"     android:layout_centervertical="true"/>   <button     android:id="@+id/topleftouter"     android:layout_width="90dp"     android:layout_height = "90dp"     android:background="#0022ff"     android:clickable="true"     android:visibility="visible"     android:adjustviewbounds="true"     android:rotation="45"     android:layout_marginbottom="67dp"     android:layout_alignbottom="@+id/bottomrightouter"     android:layout_alignleft="@+id/toprightouter"     android:layout_alignstart="@+id/toprightouter"/>   <button     android:id="@+id/toprightouter"     android:layout_width="90dp"     android:layout_height="90dp"     android:background="#00ff00"     android:clickable="true"     android:visibility="visible"     android:adjustviewbounds="true"     android:rotation="45"     android:layout_margintop="-23dp"     android:layout_below="@+id/topleftouter"     android:layout_centerhorizontal="true"/>   <button     android:id="@+id/bottomleftouter"     android:layout_width="90dp"     android:layout_height = "90dp"     android:background="#ffd000"     android:clickable="true"     android:visibility="visible"     android:adjustviewbounds="true"     android:rotation="45"     android:layout_centervertical="true"     android:layout_marginleft="78dp"/>   </relativelayout> 

the main point needed rid of layouts


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -