【问题标题】:changing xml value from java class in android studio从android studio中的java类更改xml值
【发布时间】:2016-07-11 14:34:26
【问题描述】:

我想从 java 类中更改 xml 值。

这是我的 xml 代码,我想从 java 类中设置“toDegrees”值

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="5000" >
</rotate>
</set>

如何更改 java 类中的“toDegrees”值

【问题讨论】:

    标签: java android xml


    【解决方案1】:

    使用此功能

    RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue);

    例如,你可以这样实现;

    RotateAnimation anim = new RotateAnimation(0.0f, 360.0f , Animation.RELATIVE_TO_SELF, .5f, Animation.RELATIVE_TO_SELF, .5f);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-03
      • 2016-10-20
      • 1970-01-01
      • 1970-01-01
      • 2016-03-18
      • 2017-03-06
      • 1970-01-01
      相关资源
      最近更新 更多