私は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