scale.xml
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="2.0"
android:toYScale="2.0"
android:duration="3000">
</scale>
</set>
通过以下方式以编程方式添加
TextView tv2 = (TextView) pw.getContentView().findViewById(R.id.playresultPopupYardsTextView);
Animation scale = AnimationUtils.loadAnimation(this, R.anim.scale);
scale.setStartOffset(5000);
scale.setFillAfter(true);
tv2.clearanimation();
tv2.setAnimation(scale);
pw是定义为的PopupWindow
LayoutInflater inflater = (LayoutInflater) this.getSystemService(view.getContext().LAYOUT_INFLATER_SERVICE);
final PopupWindow pw = new PopupWindow(
inflater.inflate(R.layout.playresult_popup, null, false),
700,
300,
true);
布局如下
playresult_popup.xl
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC667788"
>
<TextView
android:id="@+id/playresultPopupPlaysTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:gravity="center_horizontal"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:textSize="22sp"
android:text=""
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:gravity="center_horizontal"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:text="Yards Gained"
/>
<TextView
android:id="@+id/playresultPopupYardsTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:gravity="center_horizontal"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:textSize="18sp"
android:text=""
/>
</LinearLayout>
缩放动画运行时,它将按预期缩放文本,但是方式的每一步都朝着弹出窗口的右侧移动.我想知道这是否是因为我未声明枢轴点-如果是这样,我如何获得要使用的适当枢轴点,以便文本保持原样,只是按比例缩放?
我已经搜索过,但是找不到解释.
解决方法:
我想通了.我没有意识到可以将百分比值用作枢轴点.添加pivotX =“ 50%”和pivotY =“ 50%”解决了此问题.所以:
<scale android:fromXScale="1.0"
android:fromYScale="1.0"
android:toXScale="2.0"
android:toYScale="2.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="3000">
</scale>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。