我使用相对布局作为父视图&文本视图作为其子项..我正在将动画(缩小效果)应用于父视图,但它也应用于其子文本视图。我想仅将其动画效果应用于父视图
这是我在适配器getView()方法中的代码:
parentView =(RelativeLayout)convertView.findViewById(R.id.rel_lt);
动画动画= AnimationUtils.loadAnimation(context,R.anim.zoom_out); parentView.setAnimation(动画);
答案 0 :(得分:0)
将此布局用于动画:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/rel_lt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="#FF890009" >
</RelativeLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="TextView" />
</RelativeLayout>
不要将动画应用于根RelativeLayout。仅将动画应用于id为@ + id / rel_lt的子RelativeLayout。
希望这对你有所帮助。
答案 1 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@_id/parent_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/child_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</RelativeLayout>
现在尝试将动画发送到child_view并查看!希望这可以帮助您