2
votes

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.

5
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
How will you see it when it does't have any children..? - ngesh

5 Answers

4
votes
<?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>
2
votes

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.

1
votes

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>
1
votes

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> 
0
votes

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