AlphaAnimation does not work

前端 未结 3 408
南旧
南旧 2020-12-09 01:42

I have been looking for a solution to my problem. But my code seems to be ok.

I\'ll try to explain: I have a TextView with android:alpha=\"0\" in my layout definiti

3条回答
  •  一生所求
    2020-12-09 02:10

    actually, android have TWO alpha property for a view

        /**
         * The opacity of the View. This is a value from 0 to 1, where 0 means
         * completely transparent and 1 means completely opaque.
         */
        @ViewDebug.ExportedProperty
        float mAlpha = 1f;
    
        /**
         * The opacity of the view as manipulated by the Fade transition. This is a hidden
         * property only used by transitions, which is composited with the other alpha
         * values to calculate the final visual alpha value.
         */
        float mTransitionAlpha = 1f;
    
    
    /**
     * Calculates the visual alpha of this view, which is a combination of the actual
     * alpha value and the transitionAlpha value (if set).
     */
    private float getFinalAlpha() {
        if (mTransformationInfo != null) {
            return mTransformationInfo.mAlpha * mTransformationInfo.mTransitionAlpha;
        }
        return 1;
    }
    

    the view final alpha is the product of the TWO alpha

    View#setAlpha(float) & View#animate() & android:alpha -> mAlpha

    AlphaAnimation -> mTransitionAlpha

提交回复
热议问题