一定の変更不可能な速度が重要な場合、ObjectAnimator を「アニメーター期間スケール」開発者オプション設定から独立させるにはどうすればよいですか?
2319 次
3 に答える
12
これには明確な答えがないことに気付きました。これを行うには、リフレクションを介して隠し API を呼び出します。
// Get duration scale from the global settings.
float durationScale = Settings.Global.getFloat(context.getContentResolver(),
Settings.Global.ANIMATOR_DURATION_SCALE, 0);
// If global duration scale is not 1 (default), try to override it
// for the current application.
if (durationScale != 1) {
try {
ValueAnimator.class.getMethod("setDurationScale", float.class).invoke(null, 1f);
durationScale = 1f;
} catch (Throwable t) {
// It means something bad happened, and animations are still
// altered by the global settings. You should warn the user and
// exit application.
}
}
詳細については、このブログ投稿を確認できます: https://arpytoth.com/2016/12/20/android-objectanimator-independent-of-global-animator-duration/
于 2016-12-20T09:14:28.413 に答える
1
オブジェクトのsetDurationScale
メソッドにアクセスするには、隠し API を使用する必要がありました。ValueAnimator
于 2015-02-14T15:54:51.733 に答える