Beglarm
Beglarm

Reputation: 58

How to set spinners drop down view width?

I want to reduce width of spinner's dropdown view. my dropdown view is CheckedTextView. I set width to CheckedTextView 300dp but It didn't help. It took whole display anyway.

P.S . I wanted to post picture also but I don't have enough reputation

Upvotes: 1

Views: 5810

Answers (1)

Barney
Barney

Reputation: 2373

Make sure you're setting the layout_width attribute instead of width.

<CheckedTextView 
    android:id="@+id/myCheckedTextView"
    android:layout_width="width_you_want_in_dp"
    android:layout_height="wrap_content"/>

You can also do it programmatically like this:

myCheckedTextView.getLayoutParams().width = width_you_want_in_pixels;

Hope this helps!

Upvotes: 6

Related Questions