0

ScrollView 内で EditText にフォーカスすると、これが発生します (問題ありません)。 ここに画像の説明を入力

次に、下の EditText にフォーカスし、図 1 の EditText に再度フォーカスすると、次のようになります。 ここに画像の説明を入力

ヒントが表示されない、または表示されない (スクロールビューによる)。

解決策の一部: Scrollview は、EditText にフォーカスしたいが、囲まれた android.support.design.widget.TextInputLayout 要素にはフォーカスしたくないことを認識しています。したがって、ヒントが表示されているかどうかは気にしません。

直し方?私のXML(基本的に、EditTextsを含むandroid.support.design.widget.TextInputLayoutを含むいくつかのlinearlayoutsを持つスクロールビュー):

<ScrollView
            android:layout_width="match_parent"
            android:fadeScrollbars="false"
            android:layout_height="wrap_content">

            <LinearLayout
                android:layout_width="match_parent"
                android:orientation="vertical"
                android:layout_height="match_parent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:orientation="horizontal"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    android:weightSum="9"
                    android:descendantFocusability="beforeDescendants"
                    android:layout_height="match_parent">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:text="1"
                        android:gravity="center"
                        android:layout_height="match_parent" />

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="4">

                        <EditText
                            android:layout_width="match_parent"
                            android:layout_weight="1"
                            android:maxLines="1"
                            android:hint="hint1.1"
                            android:inputType="numberDecimal"
                            android:layout_height="match_parent" />

                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="4">

                        <EditText
                            android:layout_width="match_parent"
                            android:maxLines="1"
                            android:inputType="number"
                            android:hint="hint1.2"
                            android:layout_height="match_parent" />


                    </android.support.design.widget.TextInputLayout>

                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:orientation="horizontal"
                    android:weightSum="9"
                    android:layout_height="match_parent">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="2"
                        android:gravity="center"/>

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="4">

                        <EditText
                            android:layout_width="match_parent"
                            android:layout_weight="1"
                            android:maxLines="1"
                            android:hint="hint2.1"
                            android:inputType="numberDecimal"
                            android:layout_height="match_parent" />

                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="4">

                        <EditText
                            android:layout_width="match_parent"
                            android:layout_weight="1"
                            android:maxLines="1"
                            android:hint="hint2.2"
                            android:inputType="number"
                            android:layout_height="match_parent" />

                    </android.support.design.widget.TextInputLayout>

                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:orientation="horizontal"
                    android:weightSum="9"
                    android:layout_height="match_parent">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="3"/>

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="4">

                        <EditText
                            android:layout_width="match_parent"
                            android:hint="hint3.1"
                            android:maxLines="1"
                            android:inputType="numberDecimal"
                            android:layout_height="match_parent" />

                    </android.support.design.widget.TextInputLayout>

                    <android.support.design.widget.TextInputLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="4">

                        <EditText
                            android:layout_width="match_parent"
                            android:layout_weight="1"
                            android:hint="hint3.2"
                            android:maxLines="1"
                            android:inputType="number"
                            android:layout_height="match_parent" />

                    </android.support.design.widget.TextInputLayout>

                </LinearLayout>

            </LinearLayout>

        </ScrollView>
4

1 に答える 1

4

このコードを使用して、編集テキスト ビューの適切な位置までスクロールします。

your_scrollview.post(new Runnable() { 
@Override
 public void run() { 
       your_scrollview.smoothScrollTo(0, your_EditBox.getBottom());
 } 
});
于 2016-11-05T12:38:12.133 に答える