Misunderstanding Android weights -


i've tried couple different approaches weights, there glaring mis-understanding of how aiming here. attempting do, have imageview take 1/3rd of screen across width, while having layout of textviews take remainder of 2/3rds of screen across width.

what ends having try , manipulate however, imageview small , not taking space should be. i've been messing around trying layouts right morning.

the answer below has led me following occurring in instance:

0dip layout dimensions

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical" >      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"          android:weightsum="3">          <imageview             android:id="@+id/imageview1"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/skeleton"              android:layout_weight="1"/>          <linearlayout             android:layout_width="match_parent"             android:layout_height="match_parent"             android:orientation="vertical"              android:layout_weight="2">              <edittext                 android:id="@+id/edittext1"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:ems="10" />              <edittext                 android:id="@+id/edittext2"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_weight="1"                 android:ems="10" />          </linearlayout>      </linearlayout>  </linearlayout> 

in linear layouts, there trick make weights work - should set dimension apply weight zero.

<imageview     android:id="@+id/imageview1"     android:layout_width="0dp"     android:layout_height="wrap_content"     android:src="@drawable/display_pro_skeleton"      android:layout_weight="1"/>  <linearlayout     android:layout_width="0dp"     android:layout_height="match_parent"     android:orientation="vertical"      android:layout_weight="2">      <edittext         android:id="@+id/edittext1"         android:layout_width="match_parent"         android:layout_height="0dp"         android:layout_weight="1"         android:ems="10" />      <edittext         android:id="@+id/edittext2"         android:layout_width="match_parent"         android:layout_height="0dp"         android:layout_weight="1"         android:ems="10" />  </linearlayout> 

something this.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -