0

I am using the following 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:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="9"
        android:background="@drawable/rectangularborder"
        android:orientation="horizontal" >

        <LinearLayout

            android:layout_height="fill_parent"
            android:layout_width="0px"
            android:layout_weight="1"
            android:background="@drawable/rightrectangularborder"
            android:orientation="vertical" >
        </LinearLayout> 
        <!--

        <LinearLayout

            android:layout_height="fill_parent"
            android:layout_width="0px"
            android:layout_weight="1"
            android:background="@drawable/rightrectangularborder"
            android:orientation="vertical" >
        </LinearLayout> -->


    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="1"
        android:background="@drawable/rectangularborder"
        android:orientation="vertical" >
    </LinearLayout>

</LinearLayout>

In this border for linear layout with id linearLayout1 is not getting displayed. But when I comment the linear layout inside linearLayout1 then the border is getting properly displayed . How can I overcome the problem?

5 Answers5

0

Try adding margin to inner linear layout

android:layout_margin="2dp"
Fahim
  • 12,198
  • 5
  • 39
  • 57
0

Give some padding to Linear Layout with id linearlayout1,Like:

android:padding="10dp"
Ramesh
  • 526
  • 3
  • 14
0

Perhaps the layout that you commented out is taking more vertical space than it should? I am not sure how the "fillParent" of one layout would interact with another component whose height is specified in terms of weight.

Try experimenting with the values. Set the background color of each layout so that you know exactly where one starts and the other ends.

amahfouz
  • 2,328
  • 2
  • 16
  • 21
0

add layout_margin in your layout having id linearLayout1, such as,

android:layout_margin="12dp"
Apurva
  • 7,871
  • 7
  • 40
  • 59
0

Use android:layout_margin="10dp"

enter code here
<?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:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_margin="10dp"
        android:layout_weight="9"
        android:background="#000000"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="0px"
            android:layout_height="fill_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:background="#ffffff"
            android:orientation="vertical" >
        </LinearLayout>

        <LinearLayout
            android:layout_width="0px"
            android:layout_height="fill_parent"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:background="#ffffff"
            android:orientation="vertical" >
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_margin="10dp"
        android:layout_weight="1"
        android:background="#000000"
        android:orientation="vertical" >
    </LinearLayout>

</LinearLayout>
Bhavin Shah
  • 361
  • 4
  • 11