java - 将标准按钮动画添加到 TextView
问题描述
如果它可能重复但找不到解决方案,我深表歉意。
当我点击它时,会有一个流畅的标准动画。我怎样才能在 TextView 上做同样的事情?想象一下,我有一个橙色的 textView,其行为类似于 Button。如何向它添加相同的动画?太感谢了
解决方案
如果您的目标是 API 23 或更高版本,您可以使用background
和foreground
属性的组合:
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/orange"
android:foreground="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true" />
推荐阅读
- reactjs - 无法在不破坏父反应应用程序样式的情况下导入使用 Material UI 实现的 React 组件
- angular - 新窗口工作完成后重定向到旧窗口
- weblogic - 连接到 OEPE 中的 Oracle Weblogic Cloud 12c 服务器时出现异常
- javascript - 在创建期间设置数组长度是否有好处?
- sql - 从 2 个表中过滤并加入 2 个其他表
- reactjs - 在这种情况下如何单击按钮更改组件
- reactjs - 反应叠加层内的输入字段在模态中不起作用
- angular - 如何正确使用 Angular 中的 Observable 将数组数据从父级发送到子级?
- pandas - 如何将数据延迟加载到张量流模型中?
- kubernetes - Helmfile 如何将现有资源更改为另一个图表