我想要做一個佈局,最後一個按鈕總是在底部,並且如果需要可以滾動。這是我到目前爲止:在底部格式化按鈕的xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/gradient_bg" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<!-- Name Label -->
<TextView android:id="@+id/NameDesc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Spot Name:"
style="@style/black_text"/>
<!-- Input Name -->
<EditText android:id="@+id/inputName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_marginBottom="15dip"
android:singleLine="true"
android:capitalize="words"/>
<!-- Button Create Product -->
<Button android:id="@+id/btnDate"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Set Date"
android:tag="3"
android:onClick="onClick"
android:visibility="gone"
style="@style/btnStyleBreakerBay"/>
<TextView
android:id="@+id/txtDate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Date of Event:"
style="@style/black_text"
android:visibility="gone"/>
<Button android:id="@+id/btnTime"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Set Time"
android:tag="4"
android:onClick="onClick"
android:visibility="gone"
style="@style/btnStyleBreakerBay"/>
<TextView
android:id="@+id/txtTime"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Time of Event:"
style="@style/black_text"
android:visibility="gone"/>
<!--Type in info^ -->
<TextView
android:id="@+id/txtType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Event Type:"
style="@style/black_text"
android:visibility="gone"
/>
<Spinner
android:id="@+id/spinner_event"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/event_arrays"
android:prompt="@string/event_prompt"
android:visibility="gone"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Pavement Type:"
style="@style/black_text"
/>
<Spinner
android:id="@+id/spinner_pavement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/pavement_arrays"
android:prompt="@string/pavement_prompt" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Amount of Traffic:"
style="@style/black_text"
/>
<Spinner
android:id="@+id/spinner_traffic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/traffic_arrays"
android:prompt="@string/traffic_prompt" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Environment Type:"
style="@style/black_text"
/>
<Spinner
android:id="@+id/spinner_enviro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/enviro_arrays"
android:prompt="@string/enviro_prompt" />
<Button
android:id="@+id/btnCapturePicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Take a Picture"
android:tag="1"
android:onClick="onClick"
style="@style/btnStyleBreakerBay"/>
<TextView
android:id="@+id/txtPreview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Image Preview:"
style="@style/black_text"
android:visibility="gone"/>
<!-- To display picture taken -->
<ImageView
android:id="@+id/imgPreview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<FrameLayout
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_weight="1">
</FrameLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
<!-- Button Create Product -->
<Button android:id="@+id/btnCreate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Create Spot"
android:tag="2"
android:onClick="onClick"
style="@style/btnStyleBreakerBay"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
但我不能得到最後一個按鈕去底部。有人可以幫我嗎?我在這裏嘗試了幾個答案,但似乎沒有任何工作。也許這是因爲我如何設置其他佈局的高度,但我不太確定。
謝謝你在前進,
泰勒
謝謝!這種佈局真的很有幫助!我可能會通過我所有的XML佈局,並用它替換它們。它確實比我所做的更好地組織它! – TylerM
:)不客氣 –