【问题标题】:Move group of elements up on keyboard enter in ConstraintLayout在 ConstraintLayout 中的键盘输入上移动一组元素
【发布时间】:2020-10-04 03:44:54
【问题描述】:

我目前正在尝试将之前在 LinearLayout 中完成的视图移动到 ConstraintLayout

我面临的麻烦是我需要根据键盘向上推视图。如何创建条件链?

这就是我制作约束的方式:

通常我会使用设置为adjustResizewindow:softInputMode 属性,并且我的观点很好。即使这样,在ConstraintLayout 中也只有按钮向上移动,因为它与父级底部有约束。

我尝试创建一个从EditText 到按钮的有一定边距的有偏约束。我不能将偏差设置为零以外的任何值,否则它会将编辑文本移向按钮。

我应该如何做到这一点?

【问题讨论】:

    标签: android user-interface android-constraintlayout


    【解决方案1】:

    试试这个方法,

    在按钮和 EditText 之间添加 Space 视图,如下所示

    <Space
            android:id="@+id/space"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintBottom_toTopOf="@+id/yourButtonId"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/yourEditTextId" />
    

    【讨论】:

      猜你喜欢
      • 2015-02-12
      • 1970-01-01
      • 2017-12-25
      • 1970-01-01
      • 1970-01-01
      • 2018-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多