小编Zip*_*son的帖子

为什么在视图动画后setVisibility不起作用?

为什么textView不会变得不可见?

这是我的布局xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
    android:id="@+id/tvRotate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Rotate Me"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

..这是我的活动:

public class RotateMeActivity extends Activity
{
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView tvRotate = (TextView) findViewById(R.id.tvRotate);

        RotateAnimation r = new RotateAnimation(0, 180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        r.setDuration(0);
        r.setFillAfter(true);
        tvRotate.startAnimation(r);
        tvRotate.setVisibility(View.INVISIBLE);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的目标是旋转视图,然后通过设置setVisibility隐藏并在代码中显示它.以下工作,但setRotation仅在API级别11中可用.我需要在API级别10中执行此操作.

tvRotate.setRotation(180);//instead of the RotateAnimation, only works in API Level 11
tvRotate.setVisibility(View.INVISIBLE);
Run Code Online (Sandbox Code Playgroud)

animation android visibility rotation rotateanimation

63
推荐指数
4
解决办法
3万
查看次数