Tej*_*jjD 14 android android-layout rippledrawable android-include
我有一个布局,其中包括另一个布局:
<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>
Run Code Online (Sandbox Code Playgroud)
我需要一个RippleEffect以及一个StateListAnimator添加到包含布局.
例:
<include layout="@layout/my_layout"
android:stateListAnimator="@anim/lift_up"
android:background="@drawable/ripple_effect"/>
Run Code Online (Sandbox Code Playgroud)
RippleEffect和StateListAnimator都可以100%运行.我不能改变包含的布局.因此,我需要对include标签或父布局本身进行效果.
我尝试了两种技术,但都没有成功.
UPDATE
如果可能,应该以编程方式关闭.
更新2
其次,一旦动画,我将如何保持视图升高?
您需要找到视图并调用适当的方法来更改状态列表动画器和背景。您可能还需要在包含的布局的根视图上调用 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);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
845 次 |
最近记录: |