2017-10-28 4 views
-3

レイアウトに問題があります。キーパッド入力が表示されたときに、ScrollView内でリニアレイアウトのサイズが変更されます

私は内部に線形レイアウトを持ち、線形レイアウトの内部にはいくつかのTextInputLayoutを持っています。

ユーザがテキスト入力に集中しており、ユーザがリニアレイアウトを(テキスト入力なしで)押した場合、テキスト入力は焦点が合わなくなります。私は、入力の親線形レイアウトをフォーカス可能に設定しました。 テキスト入力ではない領域をユーザーが押して、フォーカスを合わせた入力に焦点が合わないようにします。

私のスクロールビューの幅と高さは親にマッチし、内部の線形レイアウトは画面全体をカバーする幅にマッチします。しかし、線のレイアウトの高さではなく、高さは折り返しの内容でなければなりません。

テキスト入力が集中してキーボード入力が表示されると、すべてが少し上にプッシュアップされます。

しかし、私がキーボードを越えてスクロールすると、線形レイアウトはスクロールビューだけが残っているように見えるので、もう存在しないように見えます。

adjustPan、adjustResize、fillViewPortのようなさまざまな方法を試しましたが、どれも機能しません。助けてください。私は以下の2つのスクリーンショットを添付しました。

注:視覚を容易にするために、スクロールビューの背景を紫色に、線形レイアウトを青色に設定しました。

このスクリーンショットは、アプリが起動し、キーボード入力がなく、すべて正常です。 https://i.stack.imgur.com/7MqIL.png

これはキーボード入力が表示される場所で、紫色の領域を押してフォーカスをクリアしようとすると機能しません。私は青または線形レイアウトがすべてのスクロールビューをカバーするようにしたい。 https://i.stack.imgur.com/q6jCn.png

<ScrollView 
    android:id="@+id/scrollview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    android:orientation="vertical" 
    android:background="@android:color/holo_purple" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    app:layout_constraintBottom_toBottomOf="parent"> 

    <LinearLayout 
     android:id="@+id/linearlayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp" 
     android:paddingTop="100dp" 
     android:paddingBottom="20dp" 
     android:layout_margin="0dp" 
     android:fillViewport="true" 
     android:focusable="true" 
     android:focusableInTouchMode="true" 
     android:descendantFocusability="beforeDescendants" 
     android:textAlignment="center" 
     android:layout_gravity="center" 
     android:background="@android:color/holo_blue_dark"> 

     <android.support.design.widget.TextInputLayout> 
     ... 
     ... 
    </LinearLayout> 
</ScrollView> 
+1

は質問であなたのファイルを共有します.. –

+0

すごい話題!信じられない –

答えて

0

リニアレイアウトからすべてのパディングを削除し、TextInputLayoutにそれを与えるとリニアレイアウトの高さを取る

アンドロイドのような試合の親である:layout_height =「match_content」

関連する問題