android - What's a reasonable way to make this layout? -


in image below, yellow square represents relativelayout that's within overall layout.

the top row "status message" viewflipper responds togglebuttons (a, b) user can press. buttons c, d, , e other stuff reload entire view. our client requesting buttons a, b, c, d, , e arranged in fashion below. (vertical alignment isn't important horizontal alignment.)

edit a, b, c, d, , e images 20x20 dip; being aligned within width of 300dip. want buttons maintain aspect ratio.

looking make layout

i've created extension of linearlayout inflates buttons , b (from xml file), , linearlayout inflates buttons c, d, , e in xml file.

buttons , b (are togglebuttons):

<relativelayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:baselinealigned="true" >     <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_centerhorizontal="true"     >         <togglebutton             android:id="@+id/a"             android:texton=""             android:textoff=""             android:background="@layout/a"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_marginleft="60dp"             android:layout_marginright="30dp"         />         <togglebutton             android:id="@+id/b"             android:texton=""             android:textoff=""             android:background="@layout/b"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_marginleft="30dp"             android:layout_marginright="30dp"         />     </linearlayout> </relativelayout> 

buttons c,d,e xml file:

<relativelayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:baselinealigned="true" >     <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_centerhorizontal="true"     >         <imageview              android:id="@+id/c"             android:src="@drawable/c"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_marginleft="30dp"             android:layout_marginright="30dp"         />         <imageview              android:id="@+id/d"             android:src="@drawable/d"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_marginleft="30dp"             android:layout_marginright="30dp"         />         <imageview              android:id="@+id/e"             android:src="@drawable/e"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_marginleft="30dp"             android:layout_marginright="30dp"         />     </linearlayout> </relativelayout> 

my code works, have fudge margins make things line correctly (which don't yet). wonder if there's cleaner way of center aligning button-sets "a b" , "c d e"

ps: astute reader notice i'm extending linearlayout, inflating relativelayouts. (i don't know why can work @ all, but) when tried extending relativelayout instead, "c d e" layout didn't appear on device. don't know went.

use linear layout main body.

then use layout_gravity on individual horizontal linearlayouts keep content centred

use layout_margin on each of child view space them apart. have specified 15dip should use dimension can modify them together.

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent">     <textview android:id="@+id/some_text"         android:layout_height="wrap_content"         android:text="some random string." android:layout_gravity="center" android:layout_width="wrap_content"/>     <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center">         <togglebutton             android:id="@+id/a"             android:texton=""             android:textoff=""             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:background="@layout/a"             android:layout_margin="15dip"/>         <togglebutton             android:id="@+id/b"             android:texton=""             android:textoff=""             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:background="@layout/b"             android:layout_margin="15dip"/>     </linearlayout>     <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center">         <imageview              android:id="@+id/c"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/c"             android:layout_margin="15dip"/>         <imageview              android:id="@+id/d"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/d"             android:layout_margin="15dip"/>         <imageview              android:id="@+id/e"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/e"             android:layout_margin="15dip"/>     </linearlayout>  </linearlayout> 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -