我想使用ScaleAnimation(以编程方式不在xml中)更改高度以查看父高度的0到60%.视图宽度恒定,为50px.视图为空,仅设置背景颜色.
有人可以给我代码scaleAnim从代码中使用ScaleAnimation.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/layContainer
>
<View
android:layout_width="50px"
android:layout_height="fill_parent"
android:id="@+id/viewContainer"
android:background:"#00f00"
/>
</LinearLayout>
ScaleAnimation scaleAnim = new ScaleAnimation(...);
Run Code Online (Sandbox Code Playgroud)

在动画之前和之后查看.谢谢
我有RecyclerView很多项目,基本上是一些CardView.
这些卡片在他们的身体中间有一个支持文本,GONE默认情况下可见性设置为,VISIBLE当我点击卡片右侧的箭头时,它就会生成.
我正在尝试在文本显示的同时对卡进行动画处理,同时它会崩溃.
下图显示了扩展卡和折叠卡:
该CardView布局(我已经删除了可读性某些部分):
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true"
android:id="@+id/root">
<LinearLayout
android:id="@+id/item_ll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_vertical_margin">
<!-- The header with the title and the item -->
<TextView
android:id="@+id/body_content"
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:layout_marginBottom="8dp"
android:text="@string/about_page_description"
android:textColor="@color/secondaryText"
android:visibility="gone"/>
<!-- The divider, and the footer with the timestamp -->
</LinearLayout>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
当卡片展开并露出身体时TextView,动画正在工作,但是,当我试图将其折叠回来时,动画片下方的卡片与第一张卡片重叠.
例:
我之前已经在这里问了一个关于这种行为的类似问题,但是这个解决方案并不适用TextView于卡片的中间位置.
负责动画部分的代码在RecyclerView适配器内部.箭头有一个点击监听器,可以调用以下方法:
private …Run Code Online (Sandbox Code Playgroud) android android-animation kotlin android-transitions android-recyclerview