Reputation: 307
In some ListView
's holder I got empty spaces even it has a small text in it.
TextView
is set to wrap_content
. My listview layout xml item has several buttons. I just set these buttons VISIBILITY.GONE.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/textView"
android:gravity="center" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="photo"
android:id="@+id/photo"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:baselineAligned="false"
android:clickable="false"
android:focusable="false">
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="New Button"
android:id="@+id/left" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="New Button"
android:id="@+id/right" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:baselineAligned="false"
android:clickable="false"
android:focusable="false" >
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_gravity="center_horizontal"
android:layout_weight="4"
android:gravity="center_horizontal"
android:hint="@string/answer"
android:maxLength="4" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/ok"
android:id="@+id/ok" />
</LinearLayout>
</LinearLayout>
Upvotes: 0
Views: 71
Reputation: 2186
Instead of using "match_parent" in the top use "wrap_content" for height
Upvotes: -1
Reputation: 15334
Put the root as wrap_content
instead of match_parent
for the height.
What will happen in a vertically scrolling listview (read, infinite height available for children) if it's children say they want match_parent
?
Can't see your image, but in a RecyclerView, each item's height would be the height of the RecyclerView.
Upvotes: 4