我正在使用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