2

Possible Duplicate:
Android Drawing Separator/Divider Line in Layout?

In my activity I have two Linearlayouts having weights 1 in a parent Linearlayout having weight 2. Now I want to draw a line between the two child Linearlayouts ?

Community
  • 1
  • 1
user1047892
  • 61
  • 2
  • 7

2 Answers2

5

Regardless of weight, you can draw an horizontal line by using a view, for example:

<View 
    android:layout_width="fill_parent"
    android:layout_height="1dip"
    android:background="#ffffffff" />
gwvatieri
  • 5,133
  • 1
  • 29
  • 29
0

Just make another LinearLayout between the 2 child layouts - Simple example here 2 Child LinearLayouts with 2 textviews each.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:orientation="vertical">
     <TextView  
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/hello"/>
     <TextView  
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/hello"/>
  </LinearLayout>

  <!-- In between 2 child layouts -->

  <LinearLayout
    android:layout_height="3dp"
    android:layout_width="fill_parent"
    android:background="@android:color/white"/>

  <LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:orientation="vertical">
      <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"/>
      <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"/>
 </LinearLayout>
</LinearLayout>
Sagar Devkota
  • 1,295
  • 3
  • 12
  • 25
shecodesthings
  • 1,218
  • 2
  • 15
  • 33