AndrewJM
AndrewJM

Reputation: 1376

Android Layout - fill the rest of the space except

I have a relative layout. For simplicity, there is an ImageView, EditText, and Button:

The problem is I want the editText to fill the leftover height of the screen. put and image on the top, a button on the bottom, and in the middle and edit text that takes up the rest of the space.

What property would i have to work with to get something similar to this?

Upvotes: 29

Views: 16500

Answers (2)

Sagar Hatekar
Sagar Hatekar

Reputation: 8790

Have you considered using Relative Layout?

You could use


android:layout_below
android:layout_alignParentTop
android:layout_alignParentBottom
android:layout_marginTop
android:layout_marginBottom

Try that and post some sample code if you get stuck.

Upvotes: 3

peter.bartos
peter.bartos

Reputation: 12045

For this purpose, there is LinearLayout with layout_weight property. Use LinearLayout for holding these 3 elements. For Button and ImageView, set layout_height as wrap_content. For EditText set layout_height="0dp" and layout_weight="1".

Upvotes: 68

Related Questions