android - Fill up the remaining space for GridView after a ImageView in Relative Layout -


hi making view through gridview , imageview in xml imageview shows selected image , gridview shows image.

i have imageview lets of 300 dp of width , 200 dp of height setting using below code.

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="match_parent"      android:background="@drawable/bg"> <relativelayout  android:id = "@+id/relative1" android:layout_width="fill_parent" android:layout_height="wrap_content">     <imageview    android:id="@+id/imageview1"    android:layout_width="300dp"    android:layout_height="200dp"    android:adjustviewbounds="true"    android:layout_alignparentleft="true"    android:src="@drawable/ic_launcher" /> </relativelayout>  <gridview  android:id="@+id/imagegallery" android:paddingtop="10dp" android:layout_below="@+id/relative1" android:stretchmode="columnwidth" android:cachecolorhint="#00000000" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clipchildren="true" android:horizontalspacing="5dip" android:verticalspacing="5dip" android:numcolumns="2" android:fadescrollbars ="false" >   

now want gridview takes remaining height after imageview sets up. cause not want blankspace on bottom. know can set gridview align bottom parent looks odd.

please me out.

here how using relativelayout

<relativelayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@drawable/bg"     >     <imageview         android:id="@+id/imageview1"         android:layout_width="300dp"         android:layout_height="200dp"         android:adjustviewbounds="true"         android:layout_alignparentleft="true"         android:src="@drawable/ic_launcher"     />     <gridview         android:id="@+id/imagegallery"         android:paddingtop="10dp"         android:layout_below="@+id/imageview1"         android:stretchmode="columnwidth"         android:cachecolorhint="#00000000"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:clipchildren="true"         android:horizontalspacing="5dip"         android:verticalspacing="5dip"         android:numcolumns="2"         android:fadescrollbars ="false"     > </relativelayout> 

note removed useless relativelayout surrounding imageview.
here gridview taking remaining space fill parent.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -