为什么文本视图不可见
以下是我的布局xml:
<;?xml version=“1.0”encoding=“utf-8”?>;
<;LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android"
android:layout\u width=“匹配父项”
android:layout\u height=“match\u parent”
android:orientation=“vertical”>;
<;文本框
android:id=“@+id/tvRotate”
android:layout\u width=“包装内容”
android:layout\u height=“包装内容”
android:text=“旋转我”
/&燃气轮机;
</线性布局>;
…以下是我的活动:
公共类活动扩展活动
{
@凌驾
创建时的公共void(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView-tvRotate=(TextView)findViewById(R.id.tvRotate);
RotateAnimation r=新的RotateAnimation(0,180,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
r、 设定持续时间(0);
r、 setFillAfter(true);
tvRotate.startAnimation(r);
tvRotate.setVisibility(视图.不可见);
}
}
我的目标是旋转视图,然后通过设置setVisibility在代码中隐藏和显示它。下面的方法可以工作,但是setRotation仅在API级别11中可用。我需要一种方法在API级别10中实现它
tvRotate.setRotation(180)//代替RotateAnimation,它只在API级别11下工作
tvRotate.setVisibility(视图.不可见);
对我来说,调用视图的clearAnimation
修复了这个问题。在我的例子中,我希望在将fillAfter设置为true进行转换后,将视图设置回其原始位置