2016-11-05 12 views
0

にヒントを隠し(細かい厥): enter image description hereアンドロイドTextInputLayoutフォーカス

を次に、Iは、以下のEditTextを集中し、画像一方から、次いでこれをのEditTextリフォーカス enter image description here

ヒントは表示されないか、またはひどく(スクロールビューに応じて)表示されます。

ソリューションの一部: Scrollviewは、EditTextにフォーカスを当てていて、囲まれたandroid.support.design.widget.TextInputLayout要素にフォーカスしないようにしたいと考えています。したがって、ヒントが表示されているかどうかは気にしません。

修正方法? マイXML(EditTextsでandroid.support.design.widget.TextInputLayoutを含むいくつかのlinearlayoutsと基本的にscrollview):

<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> 
+0

私はそれが表示されると思うが、あなたはcuzスクロールビューがスクロールされているのを見ることはできません。 –

+0

はい。スクロールビューを正しくスクロールさせる方法はありますか? – Christian

+1

このコードを試してみてください。.. 'your_scrollview.post(新しいRunnableを(){@Override ます。public void実行(){ your_scrollview.smoothScrollTo(0、your_EditBox.getBottom());} });' –

答えて

3

使用あなたのEditTextビューの適切な位置にスクロールするには、このコードは、

your_scrollview.post(new Runnable() { 
@Override 
public void run() { 
     your_scrollview.smoothScrollTo(0, your_EditBox.getBottom()); 
} 
}); 
関連する問題