searchfragmentという名前のこのフラグメントを作成しました。以下に、searchfragmentのレイアウトXMLファイルがあります。残念ながら、デザインは私が望むほど滑らかではありません。
最初の行:ウェルカムテキスト(機能する)2番目の行:検索入力フィールド(これも機能する)Thirt行(ここでは複雑になります):「Searchfor」という名前のテキストがあるはずです。次に、検索できるアイテム(名前、年、価格など)を含むスピナー。次に、[検索]ボタンがあります。次に、出力を並べ替えることができます。したがって、「並べ替え」のテキスト、基準のあるスピナー、並べ替えボタンがあります。最良の場合、検索セクションは左に揃え、並べ替えは右に揃える必要がありますが、それでも中央に配置します。4行目:出力フィールド。要素はすべて私のデバイスに存在するため、Eclipseのグラフィックレイアウトにはありません。私はそれを機能させるために何時間も試みましたが、あなたがあなたのオブジェクトをsseingしていないならそれはちょっと難しいです。
長いテキスト-短いタスク:デザインを最適化するのを手伝ってください。
searchfragment.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_gravity="center"
android:text="@string/welcome" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/edit_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="@string/edit_message" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|center_horizontal"
android:layout_marginTop="8dp" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_for" />
<Spinner
android:id="@+id/criterion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:entries="@array/searcharray"
android:prompt="@string/prompt" />
<Button
android:id="@+id/btnSubmit"
android:layout_width="136dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@drawable/android"
android:onClick="sendMessage"
android:text="@string/button_send" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sort_for"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<Spinner
android:id="@+id/sort"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:entries="@array/sortarray"
android:prompt="@string/prompt" />
</LinearLayout>
<Button
android:id="@+id/sort_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@drawable/android"
android:onClick="sortAgain"
android:text="@string/button_send" />
</LinearLayout>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/showResults"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
</ScrollView>
</LinearLayout>
現在のデザインの写真を追加しました。赤い枠で囲まれたスペースは3番目の「行」であり、変更する必要があります。2番目のスピナーは(理由はわかりませんが)幅が広すぎます。それは最初のものと同じくらい広いはずです。次に、すべての要素がほぼ同じ高さになり、要素が中央に配置される必要があります。