Bry*_*eld 25 android android-layout
问题如果我有以下内容:
<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>
Run Code Online (Sandbox Code Playgroud)
如何让身体(第二个EditText)填充屏幕的其余部分,但是当身体内容太长时仍然会有滚动视图?喜欢height="wrap_content"和minHeight="fill_parent"
layout_height="fill_parent" 如果你把它们放在一个scrollview中似乎没有做任何事情
我想要的一个工作示例是电子邮件应用程序撰写窗口
我试过这个,EditText元素就像是wrap_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>
Run Code Online (Sandbox Code Playgroud)
如上所述,正确的方法是使用android:fillViewport ="true"属性.
有一个例子,其中图像定位为和scrollview:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/red">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/about_us_image_1_land"
style="@style/layout_marginTop20"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18502 次 |
| 最近记录: |