我正在使用NavigationDrawer和一些片段。我用一个AutoCompleteTextView制作了一个简单的例子,但宽度不能随着屏幕尺寸拉伸。Android片段布局的宽度错误
代码fragment.java的:
fragment.xml之的public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_bestplaces, container, false);
return rootView;
}
代码:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<AutoCompleteTextView
android:id="@+id/autocomplete_find"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="Search"
android:singleLine="true" />
<Button
android:id="@+id/button_find"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Find" />
</LinearLayout>
</ScrollView>
在设计它的确定,但是当我运行应用程序时它是错误的:
有人可以帮助我吗?
你是对的我的朋友。在片段容器中,被定义为wrap_content。 **我改为match_parent **,现在工作正常。谢谢! –
Cassiano