How to set the height of items in List View?
Example:
<? XML version = "1.0" encoding = "UTF-8"?>
<Relativelayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent"
Android: layout_height = "@ dimen/buy_list_item_height"> // setting the height here does not take effect.
<! --SpecificItemContent->
</Relativelayout>
Modify as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Relativelayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">
<Relativelayout
Android: layout_width = "match_parent"
Android: layout_height = "@ dimen/buy_list_item_height" // Add another layer to set the height.
Android: layout_gravity = "center_horizontal">
<! --SpecificItemContent->
</Relativelayout>
</Relativelayout>
In addition, how to avoid repeated getivew in the List View adapter?
The width/height of List View in layout is match_parent or the specified size. If wrap_content is used, it may lead to repeated get views.