嗨我正在开发Android应用程序,我在其中使用列表视图与对话框片段。我也尝试为我的列表视图设置空视图。一切工作正常,只有我的列表视图在显示空视图后缩小。我尝试了以下方法:Android状态列表视图缩小根视图
View emptyView = inflater.inflate(R.layout.no_result_found_layout, null, false);
ViewGroup viewGroup= (ViewGroup)countryListView.getParent();
viewGroup.addView(emptyView, countryListView.getLayoutParams());
countryListView.setEmptyView(emptyView);
我也试过xml。
<LinearLayout
android:id="@+id/header_llt"
android:layout_width="match_parent"
android:layout_height="@dimen/size_100"
android:background="@color/action_bar_color"
android:elevation="3dp"
android:orientation="vertical">
<com.newActivity.views.UbuntuMediumTextView
android:id="@+id/header_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="@dimen/margin_10"
android:text="@string/select_country_hint_text"
android:textColor="@color/white"
android:textSize="@dimen/text_size_18"
android:textStyle="bold" />
<EditText
android:id="@+id/inputSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_10"
android:layout_marginLeft="@dimen/margin_10"
android:layout_marginRight="@dimen/margin_10"
android:drawableLeft="@drawable/abc_ic_search_api_mtrl_alpha"
android:drawablePadding="@dimen/view_padding_normal"
android:hint="@string/search_country_hint_text"
android:inputType="textVisiblePassword"
android:textColor="@color/white"
android:textColorHighlight="@color/white_transparent"
android:textColorHint="@color/white_transparent"
android:textSize="@dimen/text_size_16" />
</LinearLayout>
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"></ListView>
<TextView
android:id="@+id/empty_tv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/no_result_found"
android:textColor="@color/text_color_gray_light"
android:textSize="@dimen/text_size_16"
android:visibility="gone">
</TextView>
</LinearLayout>
有什么办法增加空视图后保留列表视图的宽度。需要一些帮助。谢谢
尝试设置布局参数到列表视图 – Mehta