android - stretch imagebuttons in linearlayout to use available space -


i've been playing xml in order achieve following;

first row banner (works fine). then; have 3 buttons on each row. want buttons take horizontal space (so; screen width diveded 3). also, images on buttons should resize width, without changing aspect ratio!. how can done?

next; if add rows of imagebuttons, how should 'shell' linearlayouts in scrollview maintain width distribution 3 buttons?

thnx

<?xml version="1.0" encoding="utf-8"?> 

<linearlayout     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:layout_centerhorizontal="true"     android:orientation="vertical" >      <imageview         android:id="@+id/blogbanner"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:scaletype="fitxy"         android:src="@drawable/test_banner_ad" />      <linearlayout         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:layout_weight="1" >          <imagebutton             android:id="@+id/imagebutton1"             android:layout_width="wrap_content"             android:layout_height="fill_parent"             android:layout_weight="1"             android:scaletype="fitxy"             android:src="@drawable/trololo" />          <imagebutton             android:id="@+id/imagebutton2"             android:layout_width="wrap_content"             android:layout_height="fill_parent"             android:layout_weight="1"             android:scaletype="matrix"             android:src="@drawable/scout" />          <imagebutton             android:id="@+id/imagebutton3"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_weight="1"             android:scaletype="fitend"             android:src="@drawable/painting" />      </linearlayout>      <linearlayout         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:layout_weight="1" >          <imagebutton             android:id="@+id/imagebutton4"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/whoop" />          <imagebutton             android:id="@+id/imagebutton5"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/drown" />          <imagebutton             android:id="@+id/imagebutton6"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/love" />     </linearlayout>        <linearlayout         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:layout_weight="1" >          <imagebutton             android:id="@+id/imagebutton7"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/shredder" />          <imagebutton             android:id="@+id/imagebutton8"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/frog" />          <imagebutton             android:id="@+id/imagebutton9"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:src="@drawable/yeah03" />     </linearlayout> </linearlayout> 

put 3 buttons of each row horizontal layout, use "weight" attribute define widths.

the images need have dimensions "fill_parent" & use scalexy.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -