File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes How to set layout_height of a spinner in code dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "How to set layout_height of a spinner in code dynamically" Watch "How to set layout_height of a spinner in code dynamically" New topic
Author

How to set layout_height of a spinner in code dynamically

Arslan Asif
Greenhorn

Joined: Jun 12, 2010
Posts: 8
How to set layout_height of a spinner in code dynamically as there is no equalant function to it
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

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


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Arslan Asif
Greenhorn

Joined: Jun 12, 2010
Posts: 8
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

Joined: Oct 12, 2008
Posts: 1369
    
    1

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

Joined: Oct 12, 2008
Posts: 1369
    
    1

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

Joined: Jun 12, 2010
Posts: 8
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

Joined: Oct 12, 2008
Posts: 1369
    
    1

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set layout_height of a spinner in code dynamically