android - 将 EditText 聚焦在 Horizo​​ntalScrollView 上会导致 ScrollView 隐藏 EditText

标签 android android-edittext scroll horizontalscrollview

我有一个水平 ScrollView ,占据了屏幕的右半部分。在它上面,我有一个 EditText。当我选择 EditText 编辑文本时,Horizo​​ntalScrollView 滚动到右侧。我猜它试图将 EditText 放置到最左边的位置。无论如何,由于 Horizo​​ntalScrollView 占据了屏幕的右侧,通过这样做,我将无法再看到 EditText,因为它现在被我放在屏幕左侧的内容所覆盖。当我关注其布局内的某些内容时,如何防止 Horizo​​ntalScrollView 自动滚动?

谢谢。非常感谢。

一半

编辑:发布代码。我实际上是根据生成的信息创建我的 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 聚焦在 Horizo​​ntalScrollView 上会导致 ScrollView 隐藏 EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24890787/

相关文章:

java - 打开套接字时 CPU 密集程度如何

Android EditText,minus通过inputType ="number|numberSigned|numberDecimal"转换成点事件

java - 从edittext-Android获取文本出错

javascript - 滚动功能无限滚动;使页脚无法访问

css - WordPress 主题,右侧空白

java - 使用 Espresso 测试时未在 <package> 中找到测试

android - 没有连接适配器;跳过 Material 对话框内回收器 View 的布局

android - 有 Intent 地运行 Android Activity

android - 在 Android 中使用 ViewPager 和 fragment 的 EditText 出现 NullPointerException

javascript - 更新 : Add more control: hide header on scroll and work from a certain width size