Question如果我有以下情况:
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent" android:layout_height="?" android:orientation="vertical">
<EditText android:layout_width="fill_parent" android:layout_height="?" android:hint="Subject" android:id="@+id/subject" />
<EditText android:layout_width="fill_parent" android:layout_height="?" android:id="@+id/body" />
</LinearLayout>
</ScrollView>
如何让正文(第二个 EditText)填充屏幕的其余部分,但当正文内容太长时仍然可以启动滚动视图?像一个height="wrap_content"
and minHeight="fill_parent"
layout_height="fill_parent"
如果你把它们放在滚动视图中似乎不会做任何事情
我想要的一个工作示例是电子邮件应用程序撰写窗口
我试过这个并且 EditText 元素的行为就像它们是wrapp_content并且没有发生填充。如果您输入的内容足够多,只需滚动即可
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
<EditText android:layout_width="fill_parent" android:layout_height="fill_parent" layout_weight="1" android:hint="Subject" android:id="@+id/subject" />
<EditText android:layout_width="fill_parent" android:layout_height="fill_parent" layout_weight="1" android:id="@+id/body" />
</LinearLayout>
</ScrollView>
我偶然发现了一个链接邮件应用程序源代码 http://android.git.kernel.org/?p=platform/packages/apps/Email.git;a=tree;hb=master in 我在另一个问题上接受的答案 https://stackoverflow.com/questions/3885074/make-my-activity-one-of-the-mail-apps-shown-in-the-intent-chooser/3885181#3885181。答案很简单!添加android:fillViewport="true"
to the <ScrollView...>
并添加android:layout_weight="1.0"
到您想要占用所有可用空间的视图。在此解释blogspot https://web.archive.org/web/20100818151912/http://www.curious-creature.org/2010/08/15/scrollviews-handy-trick/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)