在我的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