Reputation: 157
Just a disclaimer on my part before I start relaying my question. This is my first time posting in hopes of finding a probable solution online and I'd done prior searches on the internet but failed to find the solution to my problem.
The issue I encountered was, while trying to match the width of L2 with its parent, L4, L2 gets the width correctly but there are some paddings at all four of its sides which I can't seem to get rid off. I'd checked my layout files and activities class, and I'm sure that I'm not making any changes to the layout programmatically. My layout files are as below.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/segment_agenda"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:clickable="true"
android:orientation="horizontal"
android:weightSum="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:orientation="vertical"
android:weightSum="1"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0.8"
>
<TextView
android:id="@+id/txtStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:textColor="#FFFFFF"
android:layout_weight="0.4"
android:text="Start Time Here"
/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_weight="0.2"
android:src="@drawable/information" />
<TextView
android:id="@+id/txtEndTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:text="End Time Here"
android:textColor="#FFFFFF"
android:layout_weight="0.4"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:background="@drawable/tabbarunselectedipad"
>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:orientation="vertical" >
<TextView
android:id="@+id/txtTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:text="Title Here"
android:textColor="#333333"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txtSubtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:text="SubTitle Here"
android:textColor="#333333"
android:textSize="14sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgInfo"
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/button_info"
android:scaleType="fitXY"
android:visibility="invisible" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Problem solved, It was padding from another drawable resource that was being set programmatically as the background of my Linear Layout L4. Thanks people and sorry to trouble you guys for my carelessness, will be more careful and check through my codes thoroughly before posting for help in the future.
Upvotes: 1
Views: 3986
Reputation: 6925
Try this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/segment_agenda"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="0dp"
android:background="#0000ff"
android:clickable="true"
android:orientation="horizontal"
android:weightSum="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="#f00"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:orientation="horizontal" >
<TextView
android:id="@+id/txtStartTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_weight="0.4"
android:text="Text 1"
android:textColor="#FFFFFF" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_weight="0.2" />
<TextView
android:id="@+id/txtEndTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:layout_weight="0.4"
android:text="Text 2"
android:textColor="#FFFFFF"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:background="#37c100" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:orientation="vertical" >
<TextView
android:id="@+id/txtTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:text="Title Here"
android:textColor="#333333"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txtSubtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:text="SubTitle Here"
android:textColor="#333333"
android:textSize="14sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgInfo"
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:visibility="invisible" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Upvotes: 1
Reputation: 100
Please You Should Remove android:weightSum="1" of all places in Your layout and try..It should be work....
Upvotes: 1
Reputation: 4257
Set your layout_width="0dp" in every LinearLayout which have layout_weight param
Upvotes: 0