Reputation: 13582
What is wrong in this xml ? the two textviews don't seem to occupy same space
<LinearLayout
android:id="@+id/detail_address" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:padding="10px"
android:layout_weight="1">
<TextView android:id="@+id/address" android:text="Address:"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:textColor="@color/fontonbg"
android:gravity="right" android:layout_weight="1" />
<TextView android:id="@+id/address_details"
android:text="Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/bigfontonbg" android:textStyle="bold"
android:textSize="16sp" android:layout_toLeftOf="@+id/address_btn"
android:layout_marginLeft="10px" android:gravity="left"
android:layout_weight="1" android:layout_gravity="center_vertical" />
<ImageView android:id="@+id/address_btn" android:src="@drawable/button"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10px" />
</LinearLayout>
Upvotes: 3
Views: 2126
Reputation: 33782
android:layout_width="wrap_content"
This statment tells Android that the view wants to be just large enough to fit its own internal content, taking its own padding into account. This means that the width will depend on the length of the text on this TextView
Upvotes: 2
Reputation: 26547
When you use android:layout_weight, you should not use android:layout_width="wrap_content"
but android:layout_width="0dp"
.
Upvotes: 2