Textview上的Android缩放动画导致文本移动

Textview上的Android缩放动画导致文本移动,第1张

概述我有一个动画定义为scale.xml<?xmlversion="1.0"encoding="utf-8"?><setxmlns:android="http://schemas.android.com/apkes/android"><scaleandroid:fromXScale="1.0"android:fromYSc

我有一个动画定义为

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>

缩放动画运行时,它将按预期缩放文本,但是方式的每一步都朝着d出窗口的右侧移动.我想知道这是否是因为我未声明枢轴点-如果是这样,我如何获得要使用的适当枢轴点,以便文本保持原样,只是按比例缩放?

我已经搜索过,但是找不到解释.

解决方法:

我想通了.我没有意识到可以将百分比值用作枢轴点.添加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>
总结

以上是内存溢出为你收集整理的Textview上的Android缩放动画导致文本移动全部内容,希望文章能够帮你解决Textview上的Android缩放动画导致文本移动所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1087861.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存