Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 328
ask Avatar asked Mar 03 '12 05:03

ask


3 Answers

Add some margin or padding to your views. Alternatively, embed a <View> element with fixed 10dip height.

like image 70
slezica Avatar answered Oct 31 '22 14:10

slezica


you can use padding property so its automatically set height & width what you want...

android:padding="10dip"
like image 3
Niranj Patel Avatar answered Oct 31 '22 14:10

Niranj Patel


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.

like image 2
Brandon Avatar answered Oct 31 '22 14:10

Brandon