【发布时间】:2019-04-13 15:27:53
【问题描述】:
任何人都可以帮助我以正确的方式更改TextView 在MotionLayout 中的文本...这就是我正在做的事情。
我正在一个简单的应用程序上测试MotionLayout...
我到达Motion tutorials 上关于CustomAttributes 的部分
使用它们,您可以更改View 的BackgroundColor,也可以使用customColorValue 更改textColor
在这种情况下,您可以看到在开始和结束场景中更改此值非常有效:
<CustomAttribute
motion:attributeName="backgroundColor"
motion:customColorValue="#004A6D" />
<CustomAttribute
motion:attributeName="textColor"
motion:customColorValue="#000000" />
我还注意到有一个customStringValue,所以我想我可以将TextView 文本更改为“之前”->“之后”。但是当我尝试使用CustomAttribute 设置时,应用程序崩溃了。
在开始场景中:
<CustomAttribute
motion:attributeName="Text"
motion:customStringValue="BEFORE" />
在最后一幕中:
<CustomAttribute
motion:attributeName="Text"
motion:customStringValue="AFTER" />
在 MotionScene 外部,textView 文本是 TEST:
- 当我为结束场景设置
CustomAttribute时...文本从初始值 TEST 更改为结束 AFTER 值...所以它部分工作,但永远不会回到初始状态。 - 当
TextView上没有设置初始文本时也会发生这种情况。它可以部分工作。
所以...任何人都可以帮助我以正确的方式更改TextView 在MotionLayout 中的文本。
【问题讨论】:
-
Oscar,你找到解决办法了吗?我有同样的问题:(
-
如果没有,您是否向 Google 报告了此问题?
标签: android android-custom-attributes android-motionlayout