'How to make height more than wrap_content in Android?
I have a ListView where each objects in the list has the parameter:
android:layout_height="wrap_content"
However, this makes the objects hard to press. I don't want to increase the font size to achieve this. Instead, can I add a buffer to wrap_content?
I'd like to implement something like:
android:layout_height="wrap_content" + 10dp
How do I do this?
Thanks
Solution 1:[1]
you can use padding property so its automatically set height & width what you want...
android:padding="10dip"
Solution 2:[2]
you would have to do that programmatically most likely. Because that method wont work.
Not exact coding but along the lines:
View what_i_want_to_resize = (View)findViewById(R.id.myview);
View view_with_the_size = (View)findViewById(R.id.sizeview);
what_i_want_to_resize.setMinimumHeight(view_with_the_size.getMeasuredHeight() + 10);
Something along those lines. It is impossible to do it with XML.
You can also add padding to it.
android:padding="10dp"
That will make a padding or cushion between the views.
Solution 3:[3]
Try using android:layout_margin="10dip" or padding.
Solution 4:[4]
You have to give android:layout_height="50dp" or any figure directly
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Niranj Patel |
| Solution 2 | Brandon |
| Solution 3 | CoffeeRain |
| Solution 4 |
