textview - How can I make my Android LinearLayout weights work with values of 1 and 2? -


i'm trying make linearlayout has 3 rows, each of equal height. making using 3 linearlayouts inside main one, each layout_weight of 1.

the middle linearlayout should contain imageview, textview, imageview, weights of 1,2,1. this, inside middle linearlayout created 3.

i want textview double size of each imageview. if see code below, when layout_weight 1 inner linearlayouts have no problems, 3 appear of equal size. when set middle 1 (with id=textlayout) layout_weight=2, disappears (as seen in eclipse graphical layout viewer) , 2 others visible.

i have no idea why is... pointers?

thanks

<linearlayout     android:id="@+id/layouttop"     android:orientation="horizontal"     android:layout_height="fill_parent"     android:layout_width="fill_parent"     android:layout_weight="1"> </linearlayout>  <linearlayout     android:id="@+id/layoutmid"     android:orientation="horizontal"     android:layout_height="fill_parent"     android:layout_width="fill_parent"     android:layout_weight="1">      <linearlayout         android:orientation="horizontal"         android:layout_height="fill_parent"         android:layout_width="fill_parent"         android:layout_weight="1">         <imageview             android:layout_height="fill_parent"             android:layout_width="fill_parent">         </imageview>     </linearlayout>      <linearlayout         android:id="@+id/textlayout"         android:orientation="horizontal"         android:layout_height="fill_parent"         android:layout_width="fill_parent"         android:layout_weight="2">         <textview             android:text="status"             android:layout_width="fill_parent"             android:layout_height="fill_parent">         </textview>     </linearlayout>      <linearlayout         android:orientation="horizontal"         android:layout_height="fill_parent"         android:layout_width="fill_parent"         android:layout_weight="1">         <imageview             android:layout_height="fill_parent"             android:layout_width="fill_parent">         </imageview>     </linearlayout>  </linearlayout>  <linearlayout     android:id="@+id/layoutbottom"     android:orientation="horizontal"     android:layout_height="fill_parent"     android:layout_width="fill_parent"     android:layout_weight="1"> </linearlayout> 

you don't need additional layouts space middle row appropriately, , weights backwards. if want text 2x outer images, want 1, , outer columns 1.5

<?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:orientation="vertical">     <linearlayout android:id="@+id/layouttop"         android:orientation="horizontal" android:layout_height="0dp"         android:layout_width="fill_parent" android:layout_weight="1" android:background="#ffff0000"/>       <linearlayout android:id="@+id/layoutmid"         android:orientation="horizontal" android:layout_height="0dp"         android:layout_width="fill_parent" android:layout_weight="1">          <imageview android:layout_height="fill_parent"             android:layout_width="fill_parent" android:background="@drawable/icon"             android:layout_weight="1.5" />         <textview android:layout_height="fill_parent" android:id="@+id/textview01"             android:layout_weight="1" android:text="status" android:layout_width="fill_parent" />         <imageview android:layout_height="fill_parent"             android:layout_weight="1.5" android:background="@drawable/icon"             android:layout_width="fill_parent" />     </linearlayout>      <linearlayout android:id="@+id/layoutbottom"         android:orientation="horizontal" android:layout_height="0dp"         android:layout_width="fill_parent" android:layout_weight="1" android:background="#ff00ff00"/>   </linearlayout> 

i used icon (if have one) put picture in middle row, , colors in top , bottom in show spacing more clearly.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -