I'd like to know how to specify the height of a particular item of a ListView from java code ? Thanks
Asked
Active
Viewed 6,912 times
2 Answers
2
Well it depends how, or what your trying to accomplish, one way would be:
android:layout_height
But if you mean programmatically, check this:
How to resize a custom view programmatically?
That talks about resizing, but it should be the same concept.
-1
You can do it this way. you have that item inside your xml file, so first use findViewById() to make use of it in java, Suppose you have some view in xml than do it this way.
View view = findViewById(R.id.viewname);
And use getLayoutParams() to access height or width whatever you want to change.
view.getLayoutParams.height = 50;
view.getLayoutParams.width = 50;

DazzleGifts Apps
- 41
- 2
-
While this is usually true for most Views, a ListView will have "item" childs, so this does not apply, since you are resizing a View, then re-rendering it on the ListView functions... Also, this question was asked over 5 years ago, it is unlikely that any user will see this question again. – Bonatti Mar 16 '16 at 11:20