我試圖創建一個簡單的佈局,但找不到propper辦法做到這一點。佈局應該有3個元素:頂部的TextView,中間的EditText(帶有滾動視圖)和底部的按鈕。 我做了這個代碼:Android的佈局問題
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:weightSum="1"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout android:layout_weight="0.97"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/linearLayout18"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text:"
android:gravity="center_vertical"/>
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/txtMessage"
android:text=""/>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_weight="0.03"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/linearLayout1"
android:orientation="vertical">
<Button
android:text="Next"
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
但它給我的佈局是這樣的:正如你所看到的問題是,EditText上不會採取所有可用的垂直空間(一路按鈕)。如何解決這個問題?
兩個相同(和正確)的答案。我選擇了你的 - 你先回答:)簡單而有效的解決方案,謝謝! :) – guest86 2011-06-01 12:07:57
不貪婪但我配得上一個! :) – doNotCheckMyBlog 2011-06-01 12:11:37