我有一个水平 ScrollView ,占据了屏幕的右半部分。在它上面,我有一个 EditText。当我选择 EditText 编辑文本时,HorizontalScrollView 滚动到右侧。我猜它试图将 EditText 放置到最左边的位置。无论如何,由于 HorizontalScrollView 占据了屏幕的右侧,通过这样做,我将无法再看到 EditText,因为它现在被我放在屏幕左侧的内容所覆盖。当我关注其布局内的某些内容时,如何防止 HorizontalScrollView 自动滚动?
谢谢。非常感谢。
一半
编辑:发布代码。我实际上是根据生成的信息创建我的 EditText,所以这不是它实际的样子,但它应该捕获想法。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<View
android:layout_leftOf="@+id/Anchor"/>
<View
android:id="@+id/Anchor"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerHorizontal="true"
android:background="#000" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_rightOf="@+id/Anchor"
android:fillViewport="true" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp" >
<TableRow>
<EditText>
ABOVE is the view that is going to the left
MOre views which would cause Scrolling to the right
</TableRow>
</TableLayout>
</HorizontalScrollView>
</ScrollView>
</RelativeLayout>
最佳答案
尝试在 XML 中使用 EditText(如果使用) 机器人:重力=“中心” 删除它
关于android - 将 EditText 聚焦在 HorizontalScrollView 上会导致 ScrollView 隐藏 EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24890787/