I need to create a simple layout with two form widgets (for example - two buttons). The first one must fill all available width of the parent layout and the second one must have some fixed size.
That's what I need:
If I set FILL_PARENT to the first widget - I don't see the second one. It just blows away from a view area of the layout :) I don't know how to fix this...
The easiest way to do this is using layout_weight
with LinearLayout
. Notice the width of the first TextView is "0dp"
, which means "ignore me and use the weight". The weight can be any number; since it's the only weighted view, it will expand to fill available space.
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:layout_width="25dp"
android:layout_height="wrap_content"
/>
</LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With