- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有一个 CardView
,底部有一个支持文本,默认情况下是 GONE
。我想让卡片的这一部分只有在用户点击“ Action 箭头”时才可见,如下图所示:
我知道我可以通过简单地将 View
可见性设置为 VISIBLE
来实现,但我还想为展开和折叠事件设置动画。
为此,我在 CardView
xml 上使用了 android:animateLayoutChanges="true"
属性,它在扩展时工作得很好。但是,一旦我再次单击箭头以折叠支持文本,下面的卡片就会与我在动画期间单击的卡片重叠。如何避免这种重叠?
编辑:我知道有可能做类似 solution on this question 的事情,但它似乎过于复杂,因为存在 android:animateLayoutChanges
选项。我想知道是否可以使用该 XML 属性来解决我的问题,以保持简单。
我的动画代码如下:
Java 代码
protected void expandCard() {
if (isExpanded) {
ibt_show_more.animate().rotation(0).start();
isExpanded = false;
tv_support.setVisibility(View.GONE);
}
else {
ibt_show_more.animate().rotation(180).start();
isExpanded = true;
tv_support.setVisibility(View.VISIBLE);
}
}
XML 代码
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_small"
card_view:cardCornerRadius="2dp"
android:id="@+id/os_list_item_cv">
<RelativeLayout
android:id="@+id/os_list_item_rl_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<!-- Here goes the header, the image, the action buttons and so on -->
<!-- Omitted on purpose -->
<!-- ... -->
<!-- This is the support TextView -->
<TextView
android:id="@+id/tv_support"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/os_list_item_rl_actions"
android:text="@string/bacon_ipsum"
android:paddingBottom="24dp"
android:paddingEnd="16dp"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:visibility="gone"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
最佳答案
在更改可见性之前,添加以下代码行:
TransitionManager.beginDelayedTransition(the rootView containing the cardView, new AutoTransition());
你应该得到一个流畅的动画。在此之前还要从您的 xml 中删除“animateLayoutChanges=true”。
至于为什么会这样,调用 TransitionManager.beginDelayedTransition() 会使 TransitionManger 捕获父 ViewGroup 中的当前值并在下一个动画帧中渲染动画。在这种情况下传递的转换是 AutoTransition ,它负责父 ViewGroup 中的所有淡入淡出、移动和调整大小。
见 Transitions和 TransitionManager
还要注意在适当的情况下使用支持库中的转换,或执行必要的 API 级别检查。
关于android - 动画时在 RecyclerView 内折叠 CardView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41982987/
我需要能够在我的 javascript 中折叠/折叠各种代码片段,有点像 C# 中的#region #endregion。我找不到执行此操作的方法,有什么帮助吗? 最佳答案 窗口菜单 -> 选择首选项
折叠 Accordion 时,我注意到在这段时间内没有显示边框。例如,当 Accordion 展开时,我们会在展开时看到边界。这也可以在折叠 Accordion 时完成吗? Accordion 折叠时
是否有任何插件或快捷方式可以隐藏 Sublime Text 2 中除代码部分之外的所有内容? 我需要一次折叠除部分之外的所有部分,而不是一次折叠一个部分。 谢谢~ 最佳答案 如果将鼠标悬停在行号上,您
在 Web 应用程序中,我有一个操作可能会以各种不同的方式失败,或者最终会成功。 在这种情况下,成功和失败由 SimpleResult 的子类表示(表示 HTTP 响应) 我使用 scalaz/上的
我的数据在这样的分组方案中分为三个连续的类别: 因此,整个“OCM”组被分解为名为“N/A”、“Financials”、“Industrials”等的子组,每个子组又被分解为进一步的子组。 我在 Ex
我正在尝试猫图书馆,但我很难在我应该导入和创建的东西之间导航。我的问题如下: sealed trait Checks case class CheckViolation(id: Long, msg:
有没有办法查看当前文件中打开的折叠位置? 我个人在打开折叠和移动时遇到问题,我无法找到折叠开始的线!也许有一个选项可以在数字旁边设置一个漂亮的折叠提示。也许是这样的: + 1 void myfunc(
我正在寻找一种按空白深度折叠纯文本的方法。我更喜欢 Notepad++ 解决方案,但如果它只能在另一个编辑器中完成,我可以处理。例如 Header is arbitrary text Child i
今天早上我遇到了优秀的 jstree jQuery UI 插件。一句话——太棒了!它易于使用,易于样式化,并且可以按照包装盒上的说明进行操作。我还没有弄清楚的一件事是 - 在我的应用程序中,我想确
我有以下XAML,其中堆叠了三个组框。这些组框的标题中是复选框。 我想要实现的是:当我选中/取消选中一个框时,我希望相应的groupbox能够以平滑的动画缓慢展开/折叠。 我正在Blend 4中尝试此
我知道如何使用 zO 打开光标下的所有折叠. 但是反向怎么做呢? 我想要类似 za 的东西确实如此,但也具有递归性。 附注。我知道有 zC ,但它会关闭与当前行相关的所有父级折叠,我想关闭子级。 最佳
我试图防止点击 About Us 时导航栏崩溃部分或 Projects以下代码中的部分。我已经尝试过event.stopPropagation()在这两个按钮上,但是当 jQuery 代码执行时,导航
我有一个DataGrid。它具有DataGrid.RowDetailsTemplate。当单击一个按钮时,它应该展开/折叠;我该怎么做?
我有一个 Storyboard动画,使用Opacity属性可以使控件淡出 View 。完成后,我想将控件的“可见性”设置为“折叠”。 我也想做相反的事情...将“可见性”设置为“可见”,然后使用 St
我将 SublimeText3 用于 C++ 和 Java。我想知道是否有办法折叠文件/类中的所有方法,然后将它们全部展开,而不管插入符号在哪里。或者有没有办法列出所有的功能/方法。 基本上我希望能够
如何在 YAML 中断开长字符串(如长 url 或文件名/路径),而不会将换行符变成空格? 示例输入: url: > https://example.com/?what=Lorem %20ip
给定: import shapeless._ case class F(x: Option[Int], y: Option[Int]) 我想帮忙写一个函数,f: def f(Option[Int]::
我想测试数组是否仅包含唯一元素,我的解决方案如下: function uniqueElements(a) { var r = true; while (a) { var [el, a]
我试图在单击“项目”按钮时使“javascript 项目”和“CGI 项目”滑动切换。但是,我不太明白为什么点击时只有CGI项目按钮切换,而javascript项目按钮保持不变? 我正在尝试使用 Jq
我有一组需要在 UI 中显示的项目,例如标题和其下的项目列表。 有一个父组件,我将在其中将此数据传递到如下所示的文件. 在此基础上显示了父子布局。 现在我需要根据标题的点击展开/折叠。 有一个可以附加
我是一名优秀的程序员,十分优秀!