I have a relative layout. For simplicity, there is an ImageView
, EditText
, and Button
:
ImageView
is a banner with a fixed heightEditText
where android:layout_width="fill_parent"
Button
with a fixed width and heightThe 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?
LinearLayout also supports assigning a weight to individual children with the android:layout_weight attribute. This attribute assigns an "importance" value to a view in terms of how much space it should occupy on the screen. A larger weight value allows it to expand to fill any remaining space in the parent view.
A ConstraintLayout is a ViewGroup which allows you to position and size widgets in a flexible way. Note: ConstraintLayout is available as a support library that you can use on Android systems starting with API level 9 (Gingerbread). As such, we are planning on enriching its API and capabilities over time.
ConstraintLayout provides you the ability to completely design your UI with the drag and drop feature provided by the Android Studio design editor. It helps to improve the UI performance over other layouts. With the help of ConstraintLayout, we can control the group of widgets through a single line of code.
You can use set the layout_width or layout_width to 0dp (By the orientation you want to fill remaining space). Then use the layout_weight to make it fill remaining space.
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"
.
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