小编dra*_*awk的帖子

文本视图上的 Android 缩放动画会导致文本移动

我有一个动画定义为

规模.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>
Run Code Online (Sandbox Code Playgroud)

这是通过编程添加的

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);
Run Code Online (Sandbox Code Playgroud)

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);
Run Code Online (Sandbox Code Playgroud)

布局如下 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" …
Run Code Online (Sandbox Code Playgroud)

android android-animation

3
推荐指数
1
解决办法
3827
查看次数

标签 统计

android ×1

android-animation ×1