I have a layout for searching. In the screen, there is a search box and under search box, it shows the search result.
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:background="#FFFFFF"
android:stretchColumns="0" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:paddingTop="5dp"
android:focusableInTouchMode="true">
<EditText
android:id="@+id/searchword"
android:textSize="14sp"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:drawableLeft="@drawable/icon_search"
android:hint="@string/text_searchword">
</EditText>
</TableRow>
<TableRow
android:id="@+id/listbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
<LinearLayout
android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/emptytext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#818185"
android:textSize="25sp"
android:textStyle="bold"
android:background="#FFFFFF"
android:text="@string/empty_res"
android:gravity="center_horizontal"
android:paddingLeft="6dip"
/>
</LinearLayout>
</LinearLayout>
</TableRow>
</TableLayout>
I want that the search result shows just after the search box, but if there is no search result, the empty message should come vertically center of the block for the search result. But I failed to move it vertically center. How can it arrange the message vertically center?
Try using this layout:
You have to change list’s and text view’s visibility depending on search result.