安卓:滚动型问题 [英] Android: ScrollView Issue

查看:165
本文介绍了安卓:滚动型问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有许多问题ScrollViews。最近,我试图创建一个内容超出屏幕大小,所以我创建了父元素滚动型的新布局,并设置其宽度和高度自定义值LinearView(布局已出现对话框 - 不填充整个屏幕)。

I have had a number of problems with ScrollViews. Recently I tried to create a LinearView which content exceeds the screen size so I created the new layout with parent element ScrollView and set its width and height to custom values (the layout has to appear as dialog - not filling the whole screen).

在元素选择了红色的边框显示拥抱predefined滚动型LayoutWidth和LayoutHeight这是正常的矩形。然后我把LinearView内设置的值LayoutWidth和LayoutHeight到FILL_PARENT。

When the element is selected the red border appears to embrace the rectangle of predefined ScrollView LayoutWidth and LayoutHeight which is OK. Then I placed inside the LinearView and set the values LayoutWidth and LayoutHeight to fill_parent.

后来,当我开始的元素添加到LinearLayout中的边界(红色LILE)包裹插入的元素,而不是整个父滚动型。

Then when I started to add the elements into the LinearLayout the border (red lile) wrapped the inserted elements, not the whole parent ScrollView.

所以当的LinearLayout(滚动型的儿童)的含量超过母体的尺寸滚动型滚动并未和底部元件是简单地不可见。

So when the content of the LinearLayout (child of ScrollView) exceeded the size of parent ScrollView the scroll didn't appear and the bottom elements are simply invisible.

反正......在这种情况下,XML内容过于广泛张贴问题在这里,现在我有同样的问题与更简单的例子。

Anyway.. in that case the XML content was too extensive to post the question here and now I'm having the same problem with the more simple example.

的布局的以下部分旨在是可滚动的EditText(在情况下,用户的输入超出了窗口部件的主要尺寸)。我想了高度的EditText设置设置为120px,所以我设置父滚动型的高度设置为120px和孩子的EditText到FILL_PARENT。再次在这种情况下的EditText没有填满整个滚动型区域,但一行:

The following part of the layout is intended to be a scrollable EditText (in case the user input exceeds the primary size of the widget). I wanted to set the EditText height to 120px, so I set the parent ScrollView height to 120px and the child EditText to fill_parent. Again in this case the EditText doesn't fill the whole ScrollView area but a single line:

 <ScrollView android:layout_height="120px" android:layout_width="fill_parent">
<EditText android:id="@+id/txtContent" android:layout_height="fill_parent" android:layout_width="fill_parent" android:text="TestContent">
</EditText>
</ScrollView>

有谁知道如何重塑含量高于所以填充的EditText父控件并且如果用户的输入超过了滚动显示的控件的大小?

Does anyone know how to reshape the content above so the EditText fills the parent control and in case the user's input exceeds the control size the scroll appears?

感谢您!

编辑:

以下是在布局的屏幕截图

Below are the screenshots of the layout

删除死ImageShack链接
删除死ImageShack链接

推荐答案

您的EditText应该有 WRAP_CONTENT 的高度。 FILL_PARENT 有一个滚动型没有任何意义。如果你想在的EditText 来填补你的滚动型时,它的含量比滚动型<小/ code>,使用机器人:fillViewport =真正的滚动型

Your EditText should have a height of wrap_content. fill_parent has no meaning in a ScrollView. If you want the EditText to fill your ScrollView when it's content is smaller than the ScrollView, use android:fillViewport="true" on the ScrollView.

这篇关于安卓:滚动型问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆