Ich habe Probleme beim Lesen Animation scale duration
Flagge in Marshmallow. Derselbe Code funktioniert in einer früheren Version von Marshmallow (6.0.0).Wie zu lesen Animation Skala Dauerflagge in Marshmallow
Ich verwende android.app.Fragment.setCustomTransition()
Methode für Fragment-Animation. Wenn die Dauer der Animationsskalierung in developer option settings
0 ist, werden Fragmente nicht angezeigt. Also musste ich die Animation über diese Bedingung deaktivieren.
Mein Code-Schnipsel:
public static boolean isAnimationOff()
{
final float animatorSpeed;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
{
animatorSpeed = Settings.Global.getFloat(
context.getContentResolver(),
Settings.Global.ANIMATOR_DURATION_SCALE,
0);
}
else
{
animatorSpeed = Settings.System.getFloat(
context.getContentResolver(),
Settings.System.ANIMATOR_DURATION_SCALE,
0);
}
return animatorSpeed == 0;
}
Das Problem ist: Dieser Code true
auf jedem kehrt invoke auch wenn Dauer-Animationsgröße nicht 0
Hat konfrontiert jemand dieses Problem?
Edit1
Im Folgenden finden Sie den Code-Schnipsel, wo ich isAnimationOff()
Methode verwenden, um ein Fragment zu laden:
private void loadFragment(Fragment fragment)
{
FragmentTransaction transaction = getFragmentManager().beginTransaction();
if (!Constants.isAnimationOff())
transaction.setCustomAnimations(animSlideIn, animSlideOut);
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).replace(R.id.frameTopContainer, fragment)
.commitAllowingStateLoss();
}
EDIT2
Hier wird die individuelle Linearlayout ist, die benutzerdefinierte Eigenschaft hat:
public class FractionLinearLayout extends LinearLayout
{
DisplayMetrics matrics = getContext().getResources().getDisplayMetrics();
public FractionLinearLayout(Context context, AttributeSet attrs,
int defStyleAttr)
{
super(context, attrs, defStyleAttr);
// TODO Auto-generated constructor stub
}
public FractionLinearLayout(Context context)
{
super(context);
// TODO Auto-generated constructor stub
}
public FractionLinearLayout(Context context, AttributeSet attrs)
{
super(context, attrs);
// TODO Auto-generated constructor stub
}
public float getFractionTranslationX()
{
return getWidth() > 0 ? super.getTranslationX()/getWidth() : Float.MAX_VALUE;
}
public void setFractionTranslationX(float translationX)
{
int width = getWidth();
super.setTranslationX(width > 0 ? width * translationX : Float.MAX_VALUE);
}
public float getFractionTranslationY()
{
return getHeight() > 0 ? super.getTranslationX()/getHeight() : Float.MAX_VALUE;
}
public void setFractionTranslationY(float translationY)
{
int height = getHeight();
super.setTranslationY(height > 0 ? height * translationY : Float.MAX_VALUE);
}
public float getAnimWidth()
{
return getLayoutParams().width;
}
public void setAnimWidth(int animWidth)
{
getLayoutParams().width = animWidth;
requestLayout();
}
}
Was benötigen Sie eigentlich 'isAnimationOff' Methode für? – pskink
Ich überprüfe, ob die Animationsskala 0 ist (die Animation ist aus den Einstellungen der Entwickleroptionen ausgeschalten). wenn kein 'setCustomTransition()' aufgerufen wird, wird sonst nicht aufgerufen. – chandil03
@pskink irgendein Glück. – chandil03