Full-Screen Android Layout with 2 Rows -


i'm complete beginner android development , i'm trying feel should simple doesn't seem (for me, anyway). awesome ascii art below demonstrates layout i'm trying achieve:

--------------------- |                   | |                   | |                   | |                   | |                   | |     main view     | |                   | |                   | |                   | |                   | |                   | --------------------- ||btn a|     |btn b|| --------------------- 

the whole layout should fill screen bottom row being docked bottom of screen (gravity?) , top row taking rest of screen , should fluid (i.e. if device orientation changed this:

--------------------------- |                         | |                         | |        main view        | |                         | |                         | --------------------------- ||btn a|           |btn b|| --------------------------- 

if working in html done table element, 2 tr elements (the first rowspan of 2) , couple of td elements in second row (the second having align value set right). (for web ui guys reading this, use div elements , css layout in practice).

so, problem getting first row fill available height. write simple algorithm in java code prefer work xml layout. there easy way this? code follows:

<tablelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/layout"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:stretchcolumns="1">     <tablerow>         <webview android:id="@+id/site"             android:layout_span="3" />     </tablerow>     <tablerow>         <button android:id="@+id/back"             android:text="btn a" />         <view android:id="@+id/filler" />         <button              aroid:id="@+id/forward"             android:text="btn b" />     </tablerow> </tablelayout> 

weight correct choice, try out (tested)

<?xml version="1.0" encoding="utf-8"?> <tablelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/layout"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:stretchcolumns="1">     <linearlayout android:layout_height="fill_parent"                    android:layout_width="fill_parent"                    android:id="@+id/linearlayout2"                    android:layout_weight="1">         <webview android:layout_height="wrap_content"                   android:id="@+id/site"                   android:layout_width="wrap_content" />     </linearlayout>     <linearlayout android:id="@+id/linearlayout1"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content">         <button android:layout_weight="2"                  android:text="button"                  android:id="@+id/button1"                  android:layout_width="fill_parent"                  android:layout_height="fill_parent"></button>         <button android:layout_weight="2"                  android:text="button"                  android:id="@+id/button2"                  android:layout_width="fill_parent"                  android:layout_height="fill_parent"></button>     </linearlayout> </tablelayout> 

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 ) -