Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set layout_height of a spinner in code dynamically

 
Arslan Asif
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to set layout_height of a spinner in code dynamically as there is no equalant function to it
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By layout height, do you mean the size of the Progress bar?

If so, you will have to use appropriate style: see ProgressBarStyle XML property
 
Arslan Asif
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, i have added a spinner dynamically. But by default it is too "fat", i.e height is undesirable. I want to adjust its height. How to do it???
As statically we do it by channging layout_height.
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ProgressBar has a constructor that takes a style constant try passing appropriate progress bar style enum to it. See documentation linked to in my earlier reply.
Should be something like:

 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arslan Asif wrote:No, i have added a spinner dynamically. But by default it is too "fat", i.e height is undesirable. I want to adjust its height. How to do it???
As statically we do it by channging layout_height.


Also, when you add your spinner make sure your LayoutParams have wrap_content for height and not fill_parent.
 
Arslan Asif
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kindly give me an example, i am not getting your point. Here is the code of my spinner which i am creating dynamically


Now where to add Progress Bar to make its height small???
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bad. I took spinner to mean the animation drawable displayed in a ProgressBar when you were talking about the drop down spinner control.
Sorry for the confusion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic