android - MotionLayout issue with Buttons, EditTexts and focus
问题描述
This is my third attempt to use motionLayout and I don't want to give up again because of the issues I get in my implementation.
The problem that I am now facing is that I have a card (with some editTexts and a button) and the card can be swiped up to expand. Swiping it down lets only one editText visible.
The problem is that sometimes I get very weird and breaking issues with the button and inputs, most likely problems of focus. After I swipe the card, the button cannot be pressed (or has to be press around 20-30 times to work). What's weird is that as soon as I press the button, it looks like the ripple animation inside the button just freezes. Also some inputs can no longer be clicked. If I do manage to press the button or focus on some field, most of the time (but not always), I cannot swipe the card anymore. These are some serious issues that cannot go into production. I am not doing anything with my button or inputs in code except setting a clickListener on the button, they are just in XML for the time being so it's not an issue of Kotlin code breaking them somehow.
Can anyone please tell me what I'm doing wrong and how these issues can be avoided?
Motion Layout code:
<?xml version="1.0" encoding="utf-8"?>
<Transition android:id="@+id/transitionMinimizedToFull"
motion:constraintSetEnd="@id/full"
motion:constraintSetStart="@id/minimized"
motion:duration="300"
motion:layoutDuringTransition="honorRequest"
motion:motionInterpolator="cubic(0.4,0,0.98,0.26)">
<OnSwipe motion:dragDirection="dragUp"
motion:touchRegionId="@id/details" />
<KeyFrameSet>
<KeyAttribute android:scaleX="0.95"
android:scaleY="0.95"
motion:framePosition="0"
motion:motionTarget="@+id/details" />
<KeyAttribute android:scaleX="1.0"
android:scaleY="1.0"
motion:framePosition="100"
motion:motionTarget="@+id/details" />
</KeyFrameSet>
</Transition>
<ConstraintSet android:id="@+id/full">
<Constraint android:id="@id/details">
<Layout android:layout_width="match_parent"
android:layout_height="wrap_content"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/minimized">
<Constraint android:id="@id/details">
<Layout android:layout_width="match_parent"
android:layout_height="wrap_content"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="@+id/guideline" />
</Constraint>
</ConstraintSet>
解决方案
推荐阅读
- javascript - 如何过滤对象数组?
- sql-server - 在 SQL Server 2014 中呈现具有不同条件的分层数据
- python - 在python中重新执行for循环的当前迭代
- javascript - AJAX 函数未定义?
- django - 如何在 wagtail/django 中获取一个类别中的项目数?
- bytecode - Jasminbytecode 说它缺少指令 goto 的参数
- java - @Transactional(propagation = Propagation.SUPPORTS) 没有正在进行的事务
- json - 如何在字段值中转义 $
- java - 应用程序关闭后服务内部的功能停止
- angular - NgModules 和 Router Tree 选项卡在 Augury 中不可见