I have a ListActivity which i want to change Item height refer to device height
public class MainActivity extends ListActivity
{
.
.
.
setListAdapter(new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_list_item_1,mainMenuItems));
}
its my ListActivity on galaxy nexus S :
and on galaxy nexus 7 :
how should I define listview items height ???
The default line height of a ListView (in report view mode) is computed based on the control's font size. So to select the line height, choose a font with the right height in the ListView properties. For example, select MS Sans Serif 18.
Just adding to the previous answers, you can remove android:minWidth and android:minHeight to allow the row wrap the text or you can set the height you want. Android has a default value for list item height.
The ListView
items height are the height of item layout contents, eg android.R.layout.simple_list_item_1
height. If you want different height, create an xml file and put a android:layout_height
or android:minHeight
attribute.
This is a modified simple_list_item_1
which refers to your value
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:minHeight="@dimen/your_defined_minumum_height"/>
and in your dimen.xml
<dimen name="your_defined_minumum_height">48dp</dimen>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With