我有一个布局,其中包括另一个布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/layout1">
<include layout="@layout/my_layout"/>
</LinearLayout>
我需要将 RippleEffect 和 StateListAnimator 添加到包含的布局中。
Example:
<include layout="@layout/my_layout"
android:stateListAnimator="@anim/lift_up"
android:background="@drawable/ripple_effect"/>
RippleEffect 和 StateListAnimator 都可以 100% 工作。我无法更改包含的布局。这就是为什么我需要在包含标签或父布局本身上执行效果的原因。
我尝试过这两种技术,但都没有成功。
UPDATE
如果可能的话,应该以编程方式将其关闭。
UPDATE 2
第二,我该如何保持视图的高度 https://stackoverflow.com/questions/34739041/android-permanently-elevate-view,一旦动画化?
您需要找到视图并调用适当的方法来更改状态列表动画器和背景。您可能还需要在包含的布局的根视图上调用 setClickable。
LinearLayout layout1 = findViewById(R.id.layout1);
View root = layout1.getChildAt(0);
StateListAnimator sla = AnimatorInflater.loadStateListAnimator(context, R.anim.lift_up);
root.setStateListAnimator(sla);
root.setBackground(R.drawable.ripple_effect);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)