Layout weightSum not working Android -
i have layout parent linearlayout weightsum of 100 , 2 child layouts weights 40 , 60.
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:orientation="horizontal"     android:id="@+id/cv_container"     android:layout_width="match_parent"     android:layout_height="150dp"     android:weightsum="100"     android:background="@android:color/white">     <relativelayout         android:padding="10dp"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:id="@+id/linearlayout1"         android:layout_weight="40">         <droid.squareimageview             android:src="@android:drawable/ic_menu_gallery"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:id="@+id/imgplaceholderimage"             android:layout_centerinparent="true"             android:scaletype="fitxy" />         <droid.customtextview             android:text="category"             app:customfont="fonts/roboto-bold.ttf"             android:textsize="12sp"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:color="@android:color/white"             android:id="@+id/txtcategory"             android:layout_alignparentbottom="true"             android:layout_alignparentright="true"             android:ellipsize="end" />     </relativelayout>     <linearlayout         android:orientation="vertical"         android:layout_width="0dp"         android:layout_height="match_parent"         android:id="@+id/linearlayout2"         android:layout_weight="60"         android:padding="10dp">         <droid.customtextview             android:text=""             app:customfont="fonts/roboto-bold.ttf"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:textsize="16sp"             android:color="@android:color/black"             android:id="@+id/txttitle" />         <droid.customtextview             android:text=""             android:textsize="14sp"             app:customfont="fonts/roboto-regular.ttf"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:color="#d5d5d5"             android:id="@+id/txtdate" />         <droid.customtextview             android:text=""             app:customfont="fonts/roboto-regular.ttf"             android:textsize="15sp"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:color="@android:color/black"             android:id="@+id/txtdetail"             android:maxems="4"             android:ellipsize="end" />     </linearlayout> </linearlayout> my second row looks fine, first 1 looks weird. iam using recyclerview. 
how can make first row second one?
try 0dp width relativelayout , whenever have used weight properties layout or views have set width or height 0dp on respective of parent layout orientation if parent layout horizontal set width 0dp or if parent layout vertical set height 0dp.
you not required given weightsum 100 layout or view default considering weightsum 100.

Comments
Post a Comment