Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

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

Open
ahmadalibaloch opened this issue Sep 29, 2016 · 4 comments
Open

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

ahmadalibaloch opened this issue Sep 29, 2016 · 4 comments

Comments

@ahmadalibaloch
Copy link

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

milosmns commented Sep 29, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants