在我的Android應用程序中,我有一個選項卡Activity
。在其中一個標籤中,我有兩個TextView
和兩個EditText
s。第一個EditText
只有一行,這沒關係。但是,我希望其他EditText
,android:id="@+id/paste_code"
佔用剩餘的空間,但無論我做什麼,它只會顯示一行。我不想手動設置行數,因爲適合屏幕的數量因您的設備而異。Android EditText不會佔用剩餘空間
下面是相關的代碼。它嵌套在標籤爲Activity
的所有必要組件中。
<ScrollView
android:id="@+id/basicTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Paste title"
android:layout_weight="0" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/paste_title_hint"
android:id="@+id/paste_title"
android:lines="1"
android:gravity="top|left"
android:layout_weight="0" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Paste text"
android:layout_weight="0" />
<EditText
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:hint="@string/paste_hint"
android:id="@+id/paste_code"
android:gravity="top|left"
android:layout_weight="1" />
</LinearLayout>
</ScrollView>
確實;謝謝你。我用另一個SO問題的鏈接評論了另一個答案,這個問題解決了我的問題。 – Jamie 2010-10-12 00:46:52
工程就像一個魅力! – Damjan 2011-09-30 10:32:50