После установки setEmptyView
кнопка, которая ранее была внизу, теперь поднимается до верхней части макета. Пожалуйста, помогите мне понять, почему. Вот мой код:Кнопка теперь находится в верхней части после установки setEmptyView
activity_list.xml:
<?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:gravity="top|center"
android:orientation="vertical" >
<ListView
android:id="@+id/listview_snyc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</ListView>
<Button
android:id="@+id/button_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:gravity="center"
android:text="Sync" />
</LinearLayout>
activity_list_empty.xml:
<?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" >
<ImageView
android:id="@+id/imageview_empty"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/empty" />
</RelativeLayout>
Java код:
list = (ListView) findViewById(R.id.listview_snyc);
list.setAdapter(new MasterFileMenuAdapter(this,data));
View emptyView = getLayoutInflater().inflate(R.layout.activity_list_empty, null);
addContentView(emptyView, list.getLayoutParams());
list.setEmptyView(emptyView);
Всякий раз, когда ListView
пуст Я получил этот результат:
Refresh Кнопка должна быть в нижней не на верхней.
Любая идея?
попытка изменить 'андроида: layout_height = "wrap_content"' 'для Android: layout_height = "0dp"' 'в вашем ListView' –
@ PhanVănLinh, я попробовал это, но я не могу видеть пустое изображение. –