Android 如何仅为父视图应用动画?

Android 如何仅为父视图应用动画?,android,android-animation,Android,Android Animation,我使用相对布局作为父视图,文本视图作为其子视图。。我将动画(缩小效果)应用于父视图,但它也应用于其子文本视图。我只想将其动画效果应用于父视图 这是我在adapters getView()方法中的代码: parentView=(RelativeLayout)convertView.findViewById(R.id.rellt) 动画=AnimationUtils.loadAnimation(上下文,R.anim.zoom_out); 设置动画(动画) 将此布局用于动画: <?xml ver

我使用相对布局作为父视图,文本视图作为其子视图。。我将动画(缩小效果)应用于父视图,但它也应用于其子文本视图。我只想将其动画效果应用于父视图

这是我在adapters getView()方法中的代码:

parentView=(RelativeLayout)convertView.findViewById(R.id.rellt)

动画=AnimationUtils.loadAnimation(上下文,R.anim.zoom_out);
设置动画(动画)

将此布局用于动画:

<?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>

不要将动画应用于根相对论。仅将动画应用于id@+id/rel\u lt.的子RelativeLayout。

希望这对您有所帮助。


<?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_视图提供动画并查看希望这对您有所帮助

您可以检查以下链接以解决您的需要吗?嘿,凯文,我以前试过那个链接,但那个链接和我要找的不一样。这是旋转效果&我只在视图背景上寻找缩小效果。好的,然后你尝试创建一个父布局,在其中创建一个与上一个布局匹配的多个布局。不要再在父布局中添加子视图,并为第二个布局提供动画。这太棒了@ShekharMangarule。继续前进!请接受有用的答案,以备将来参考!