display two layouts - android-layout

I am trying to build a program where users data is displayed in table view while Home,About and Settings are to be displayed in TabLayout just below the table layout but TabLayout is not shown on screen while program runs. Here I have two class file one to display table layout whereas another to display TabLayout.Below is my main.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="7dp">
<TextView
android:id="#+id/item_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="2dp"
android:textSize="10dp" />
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:minWidth="40dp" android:background="#drawable/top_left" android:textColor="#ffffffff"/>
<TextView android:text="Civil Bank " android:paddingLeft="5dp" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:minWidth="40dp" android:background="#drawable/top_middle" android:textColor="#ffffffff"/>
<TextView android:text="Sunrise Bank" android:paddingLeft="5dp" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:minWidth="40dp" android:background="#drawable/top_right" android:textColor="#ffffffff"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="Web user" android:paddingLeft="5dp" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/webuserTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/S_webuserTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="Transfer" android:paddingLeft="5dp" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/transferTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/S_transferTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView android:text="Cash" android:paddingLeft="5dp" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_right" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/cashTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_middle" android:textColor="#ffffffff"/>
<TextView android:text="0.00" android:paddingLeft="5dp" android:id="#+id/S_cashTxtView" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content" android:background="#drawable/bottom_left" android:textColor="#ffffffff"/>
</TableRow>
<TabHost
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
</TableLayout>
</LinearLayout>

You have given the width and height of your tablelayout as fill-parent.So it would probably occupy the whole space of your linearlayout. Instead of fill-parent you have to use wrap-content. In tabhost you use the property android:layout_below="#+id/yourTableLayout".

Related

adding admobs on my android app

Please assist with something,I am trying to add admobs on the app but it doesn't show on the app when I run it, but it appears on the android studio preview. How do I fix that?
This code is on the main activity layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/relatively"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#d15400"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.90"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:id="#+id/linearLayout11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<TextView
android:id="#+id/score"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:gravity="center"
android:text="Score : 1"
android:textColor="#ffffff"
android:textSize="25.0sp"
android:textStyle="bold" />
<TextView
android:id="#+id/timers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:gravity="center"
android:text="00:00:49"
android:textColor="#ffffff"
android:textSize="25.0sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.60"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.40" >
<TextView
android:id="#+id/txtQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="15*2*1-1"
android:textColor="#ffffff"
android:textSize="35.0sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:orientation="vertical"
android:weightSum="1" >
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_marginTop="5dp"
android:background="#fff"
android:gravity="center"
android:text="30"
android:textColor="#000000"
android:textSize="25.0sp" />
<Button
android:id="#+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_marginTop="5dp"
android:background="#fff"
android:gravity="center"
android:text="29"
android:textColor="#000000"
android:textSize="25.0sp" />
<Button
android:id="#+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_marginTop="5dp"
android:background="#fff"
android:gravity="center"
android:text="32"
android:textColor="#000000"
android:textSize="25.0sp" />
<!-- view for AdMob Banner Ad -->
</LinearLayout>
</LinearLayout>
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>
this code is on the questions activity class -
setContentView(R.layout.activity_main);
AdView adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.setRequestAgent("android_studio:ad_template").build();
adView.loadAd(adRequest);

How to center a LinearLayout in RelativeLayout?

I would like to center a LinearLayout in a RelativeLayout but i have a problem, the margin-bottom stays attached to bottom. Here is the view :
http://nsa33.casimages.com/img/2013/03/12//130312103139937791.png
And here is the code of the layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/group_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/carreGlobalInterieur"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#color/grisTresClair" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/border_deals"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/GroupLigneOne"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/grisClair"
android:orientation="vertical" >
<TextView
android:id="#+id/CategorieDeal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="My Category"
android:textColor="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<TextView
android:id="#+id/nouveauPrixVert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10.99 €"
android:textColor="#color/green"
android:textStyle="bold" />
<TextView
android:id="#+id/ancienPrixRouge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:layout_marginRight="6dp"
android:text="20.90 €"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/red"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:id="#+id/reductionPrix"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4dp"
android:text="(-34%)"
android:textColor="#color/red"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/ligneTwo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="3dp"
android:orientation="vertical" >
<TextView
android:id="#+id/titreEnGros"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:text="Here is an example of a compleete title in a TextView Android"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:textSize="16sp" />
</LinearLayout>
<RelativeLayout
android:id="#+id/ligneFour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:orientation="vertical" >
<TextView
android:id="#+id/dateAjout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="il y a 2 heures" />
<TextView
android:id="#+id/siteWeb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="Amazon" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
If you have some ideas to center the block, please help me !
When using the RelativeLayout, you can use android:layout_centerInParent="true", which will do what it says, center it inside its parent.

Android Layout(User Interface)

Hi i want to develop a UI like image, is it possible in android,if possible , how can we do that?(i need lines(horizontal and vertical) between images like image).
Using LinearLayout this layout is very simple.
Try below code
<?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:weightSum="4"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Find Dishes"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="3dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Recomanded Dishes"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="3dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="2" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="follow people"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<View
android:layout_width="3dp"
android:layout_height="fill_parent"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View Profile"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="3dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="2" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notifications"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<View
android:layout_width="3dp"
android:layout_height="fill_parent"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign up/Sign-In"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
After using this code my output is like this
change image and background according to your requirement.

Align Linear Layout to the bottom

I have a layout and I want the last LinearLayout to be aligned on the very bottom. I attempted to set the gravity and the android:layout_marginbottom=0dp and neither one seems to align it to the bottom.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/item_detail_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".ItemDetailActivity" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="154dp" >
<ImageView
android:id="#+id/albumArt"
android:layout_width="140dp"
android:layout_height="138dp"
android:src="#drawable/stealyourface" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill_horizontal|center"
android:orientation="vertical" >
<TextView
android:id="#+id/artistName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#E6E6E6" />
<TextView
android:id="#+id/showLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#E6E6E6" />
<TextView
android:id="#+id/showDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#E6E6E6" />
<TextView
android:id="#+id/runningSong"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#E6E6E6" />
</LinearLayout>
<TextView
android:id="#+id/currentlyPlaying"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/TwentyPixels"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#E6E6E6" />
</LinearLayout>
<ScrollView
android:id="#+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="214dp"
android:background="#000000" >
<LinearLayout
android:id="#+id/songList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<!-- Player Buttons -->
**<LinearLayout
android:id="#+id/LinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:layout_marginBottom="0dp">
<RelativeLayout
android:layout_width="320dp"
android:layout_height="wrap_content"
android:background="#layout/rounded_corner"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<!-- Previous Button -->
<!-- Backward Button -->
<!-- Play Button -->
<ImageButton
android:id="#+id/btnPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnNext"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/btnBackward"
android:background="#null"
android:src="#drawable/btn_play" />
<!-- Forward Button -->
<!-- Next Button -->
<ImageButton
android:id="#+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/btnPlay"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#null"
android:src="#drawable/btn_previous" />
<ImageButton
android:id="#+id/btnBackward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/btnPrevious"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/btnPrevious"
android:background="#null"
android:src="#drawable/btn_backward" />
<ImageButton
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="false"
android:layout_alignTop="#+id/btnForward"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_toRightOf="#+id/btnForward"
android:background="#null"
android:src="#drawable/btn_next" />
<ImageButton
android:id="#+id/btnForward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/btnPlay"
android:background="#null"
android:src="#drawable/btn_forward" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>**
You have to use android:layout_gravity to do that, not android:gravity.
http://developer.android.com/reference/android/widget/FrameLayout.html
layout_gravity specifies the gravity in respect to the parent, gravity controls the placement of the content in the view itself.
You should take a relative layout as inner layout of linear layout. Like this example. I hope its useful for you.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/mainact"
android:weightSum="6" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:clickable="true"
android:onClick="func"
android:src="#drawable/somnath" />
<ImageView
android:id="#+id/imageView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:clickable="true"
android:onClick="func"
android:src="#drawable/ghrishneshwar" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/mallikarjun" />
<ImageView
android:id="#+id/imageView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/kedarnath" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/mahakaleshwar" />
<ImageView
android:id="#+id/imageView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/trayambkeshwar" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/omkareshwar" />
<ImageView
android:id="#+id/imageView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/kashim" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="90dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/vaidyanath" />
<ImageView
android:id="#+id/imageView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="90dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/nageshwar" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="170dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/bhimashankar" />
<ImageView
android:id="#+id/imageView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="170dp"
android:clickable="true"
android:onClick="func"
android:src="#drawable/rameshwaram" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>

GridView does not fill screen

I have a "grid_test.xml"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayoutGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<GridView
android:id="#+id/gridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="5dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp" >
</GridView>
</LinearLayout>
I am including this in another layout with header and footer:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/commonlayout" >
<LinearLayout android:id="#+id/llheader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#android:color/white">
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_gravity="center">
<Button
android:id="#+id/Button_Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="2dp"
android:layout_centerVertical="true"
android:background="#drawable/ic_launcher"/>
<Button
android:id="#+id/Button_settings"
android:layout_marginLeft="2dp"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/ic_launcher"/>
</RelativeLayout>
</LinearLayout>
<ScrollView android:id="#+id/svdata"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:layout_below="#+id/llheader"
android:layout_above="#+id/llfooter" >
<LinearLayout
android:id="#+id/lldata"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backgound_color"
android:orientation="vertical"
android:padding="5dp" >
<include layout="#layout/grid_test" />
</LinearLayout>
</ScrollView>
<LinearLayout android:id="#+id/llfooter"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_margin="0dp"
android:layout_alignParentBottom="true"
>
<RadioGroup
android:id="#+id/radiogroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/black"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/btnOption1"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"
android:singleLine="true"/>
<RadioButton
android:id="#+id/btnOption2"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"
android:singleLine="true"/>
<RadioButton
android:id="#+id/btnOption3"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"/>
</RadioGroup>
</LinearLayout>
</RelativeLayout>
My problem is that the included GridView layout does not fill the screen between header and footer.
What could be causing the problem?
Ok. I found it. Removing the ScrollView, makes it work as expected.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/commonlayout" >
<LinearLayout android:id="#+id/llheader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#android:color/white">
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_gravity="center">
<Button
android:id="#+id/Button_Logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="2dp"
android:layout_centerVertical="true"
android:background="#drawable/ic_launcher"/>
<Button
android:id="#+id/Button_settings"
android:layout_marginLeft="2dp"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/ic_launcher"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/lldata"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/backgound_color"
android:orientation="vertical"
android:layout_below="#+id/llheader"
android:layout_above="#+id/llfooter"
android:padding="5dp" >
<include layout="#layout/grid_test" />
</LinearLayout>
<LinearLayout android:id="#+id/llfooter"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_margin="0dp"
android:layout_alignParentBottom="true"
>
<RadioGroup
android:id="#+id/radiogroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:color/black"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/btnOption1"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"
android:singleLine="true"/>
<RadioButton
android:id="#+id/btnOption2"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"
android:singleLine="true"/>
<RadioButton
android:id="#+id/btnOption3"
style="#style/navbar_button"
android:drawableTop="#drawable/ic_launcher"/>
</RadioGroup>
</LinearLayout>
</RelativeLayout>

Resources