我的布局有问题。
我的内部滚动视图有线性布局,线性布局内部有一些TextInputLayout。
如果用户专注于文本输入并且用户按下了线性布局(没有任何文本输入),则文本输入将不会聚焦。我已将输入的父级线性布局设置为可聚焦。 我希望用户按下任何不是文本输入的区域,并且聚焦的输入将没有聚焦。
这就是为什么我的滚动视图宽度和高度与父级匹配,并且其内部的线性布局与其宽度匹配为其覆盖整个屏幕的父级。但不是线性布局的高度,因为高度应该是换行内容
当文本输入被聚焦并且键盘输入显示时,所有内容都会被推高一点,我可以垂直滚动它们。
但是,当我向下滚动键盘以外时,线性布局似乎不再存在,因为它似乎被裁剪掉只留下滚动视图,这意味着如果用户按下那里它们将不会没有聚焦。
我尝试过各种方法,如adjustPan,adjustResize,fillViewPort Weight,但它们都不起作用。请帮忙。我在下面附上了两个截图。
注意: 我将Scroll View背景设置为紫色,将Linear Layout设置为蓝色,以便于可视化。
这个截图是应用程序启动时,没有键盘输入,一切都很好。 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>
答案 0 :(得分:0)
从线性布局中删除所有填充并在TextInputLayout中赋予它并采用线性布局的高度匹配父类似
机器人:layout_height = “match_content”