ask
ask

Reputation: 2220

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

Upvotes: 6

Views: 4583

Answers (5)

Ronak Mehta
Ronak Mehta

Reputation: 5979

You have to give android:layout_height="50dp" or any figure directly

Upvotes: 0

azizbekian
azizbekian

Reputation: 62189

Try using android:layout_margin="10dip" or padding.

Upvotes: 2

Brandon
Brandon

Reputation: 703

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.

Upvotes: 2

Niranj Patel
Niranj Patel

Reputation: 33238

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

android:padding="10dip"

Upvotes: 4

salezica
salezica

Reputation: 76899

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

Upvotes: 5

Related Questions