2

I am working with layout like in below xml 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:background="@drawable/background"
android:orientation="vertical" >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/title" >
</RelativeLayout>

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="none">

    <RelativeLayout
        android:id="@+id/rel2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_width="250dp"
            android:layout_height="50dp"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="10dp"
            android:background="@drawable/bkg_gold_btn"
            android:text="Button 1" />

        /*--------------------------------*/
        /* there are 12 more Buttons Here */
        /*--------------------------------*/
        <Button
            android:id="@+id/button10"
            android:layout_width="250dp"
            android:layout_height="50dp"
            android:layout_below="@+id/button9"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="10dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/bkg_gold_btn"
            android:text="Button 14" />
    </RelativeLayout>
</ScrollView>

  <LinearLayout
      android:id="@+id/add_layer"
      android:layout_width="fill_parent"
      android:layout_height="50dip"
      >
  </LinearLayout>

</LinearLayout>

But when I run the code I could not see LinearLayout at Bottom. please help me.

Jignesh Ansodariya
  • 12,583
  • 24
  • 81
  • 113
  • Try adding an element _inside_ the last `Linear Layout` to check if it's really showing up. You probably won't be able to see it in UI runtime since it's just a layout and not a UI element. – Ghost Mar 30 '12 at 05:58
  • How will you see it when it does't have any children..? – ngesh Mar 30 '12 at 05:58

5 Answers5

4
<?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:background="@drawable/background"
android:orientation="vertical" >

<RelativeLayout
android:id="@+id/reltop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/title" >
</RelativeLayout>

<ScrollView
android:layout_below="@id/reltop"
android:layout_above="@id/add_layer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none">

<RelativeLayout
    android:id="@+id/rel2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/button1"
        android:layout_width="250dp"
        android:layout_height="50dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:background="@drawable/bkg_gold_btn"
        android:text="Button 1" />

    /*--------------------------------*/
    /* there are 12 more Buttons Here */
    /*--------------------------------*/
    <Button
        android:id="@+id/button10"
        android:layout_width="250dp"
        android:layout_height="50dp"
        android:layout_below="@+id/button9"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/bkg_gold_btn"
        android:text="Button 14" />
</RelativeLayout>
</ScrollView>

<LinearLayout
  android:id="@+id/add_layer"
  android:layout_width="fill_parent"
  android:layout_alignParentBottom="true"
  android:layout_height="50dip"
  >
</LinearLayout>

</RelativeLayout>
Win Myo Htet
  • 5,377
  • 3
  • 38
  • 56
2

You cant see this LinearLayout coz, Parent LinearLayout is not Scrollable, and Scrollview is covering all the screen, to solve this situation, you have two options, either fix the height of ScrollView to some fixed part of the screen using weight, or pixels. Or have RelativeLayout as parent of LinearLayout and Scrollview. Set LinearLayout at bottom of parent, and scroll view aboue of LinearLayout.

jeet
  • 29,001
  • 6
  • 52
  • 53
1

Add android:gravity="bottom" android:layout_gravity="bottom" inside LinearLayout and try adding components in LinearLayout.

or replace that linear layout by relative layout like this :

 <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom" >

        <Button
           ... />
    </RelativeLayout>
Shruti
  • 1
  • 13
  • 55
  • 95
1

The Bottom LinearLayout is not visible to you, might be because of the ScrollView is takes the remaining space of the Screen to show that n numbers of button in it cause you gave it height of wrap_content.

You can use weightSum attributr of LinearLayout to define that how much area of screen will be covered by the view.

<?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="10"
android:background="@drawable/background" 
android:orientation="vertical" > 

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_weight="1"
    android:layout_height="0dp" 
    android:background="@drawable/title" > 
</RelativeLayout> 

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_weight="8"
    android:layout_height="0dp"
    android:scrollbars="none"> 

    <RelativeLayout 
        android:id="@+id/rel2" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" > 

    </RelativeLayout> 
</ScrollView> 

  <LinearLayout 
      android:id="@+id/add_layer" 
      android:layout_width="fill_parent" 
      android:layout_weight="1"
      android:layout_height="0dp"
      > 
  </LinearLayout> 

</LinearLayout> 
MKJParekh
  • 34,073
  • 11
  • 87
  • 98
0

You can move the bottom LinearLayout to the bottom of RelativeLayout(id/rel2), then you'll see it

Qiang Jin
  • 4,427
  • 19
  • 16