milosmns / actual-number-picker

Android: A horizontal number picker
GNU General Public License v3.0
222 stars 36 forks source link

I can't make the view width "match_parent" #4

Open ahmadalibaloch opened 7 years ago

ahmadalibaloch commented 7 years ago

In no way, the control is being expanded to its parent width. Nothing works in the layout_width, even not hard coded dps. It only spans a little part of the parent width in a Linear Layout which has orientation vertical.

milosmns commented 7 years ago

Would you really want to expand to match_parent? The number of lines in the picker is fixed, so it would look really wierd if you don't control the width. You can check out the #onMeasure() method to see what's happening.

Setting the width to wrap_content should resize it to match the number of visible buttons (either 0, 3 or 5 are visible), and setting the witdh in DP should work as well - I use it in several places and it works fine. Can you post your layout here? I can check what's wrong

milosmns commented 7 years ago

I used it in a project on GitHub, even weight worked. Maybe Android Studio is having issues rendering it, did you try it on a device?

Layout: https://github.com/milosmns/contacts-generator-android/blob/master/app/src/main/res/layout/activity_main.xml

Style: https://github.com/milosmns/contacts-generator-android/blob/master/app/src/main/res/values/view_styles.xml

ahmadalibaloch commented 7 years ago

I have uploaded the layout here: https://github.com/ahmadalibaloch/Code2Discuss/blob/master/quotation_edit_dialog.xml You can see how it look in preview and same in real device, If i increase the height it increases the width too. width is controller by height

milosmns commented 7 years ago

Understood. Can you try to remove the buttons? You can use show_controls and show_fast_controls to hide them. Width is tied to height only when buttons are visible.

For the time being, you could add your own arrow buttons next to the picker (if you need them) and I'll look into the issue when I have some spare time.