android - How to give equal height between 2 linear layout -
i have 2 linearlayouts of weight1,with 1st layout,if add occupies full width instead of half of screen,how avoid this
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:weightsum="2" tools:context="com.example.testapp1.mainactivity" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="@color/aqua" android:orientation="vertical" android:weightsum="2" > <linearlayout android:id="@+id/subview_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/green" android:orientation="vertical" > <relativelayout android:id="@+id/insidelayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/yellow" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/aqua" android:orientation="vertical" > <view android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/darkgray" /> </linearlayout> </relativelayout> </linearlayout> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="@color/blueviolet" android:orientation="vertical" > </linearlayout> </linearlayout>
on adding view tag,it occupies full width instead of half specified in weight1,what problem making
let's simplify problem. below should work. recommend imagine weight
percentage of 100 , if want half , half 50,50 (if wanted third each 33,33,33). no need weightsum have been removed. missing layout_height
of 0dip
allows weight
define space taken.
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.testapp1.mainactivity" > <linearlayout android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="50" android:orientation="vertical"> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="50" android:orientation="vertical" > </linearlayout> </linearlayout>
Comments
Post a Comment