Java Code Examples for com.nineoldandroids.view.ViewHelper.setAlpha()

The following are Jave code examples for showing how to use setAlpha() of the com.nineoldandroids.view.ViewHelper class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: HutHelper   File: DragLayout.java   View Source Code Vote up 6 votes
private void animateView(float percent) {
    float f1 = 1 - percent * 0.3f;
    ViewHelper.setScaleX(vg_main, f1);   //主布局逐渐变大
    ViewHelper.setScaleY(vg_main, f1);
    ViewHelper.setTranslationX(vg_left, -vg_left.getWidth() / 2.3f
            + vg_left.getWidth() / 2.3f * percent);
    ViewHelper.setScaleX(vg_left, 0.5f + 0.5f * percent);//左边的布局逐渐变小
    ViewHelper.setScaleY(vg_left, 0.5f + 0.5f * percent);
    ViewHelper.setAlpha(vg_left, percent);
    if (isShowShadow) {
        ViewHelper.setScaleX(iv_shadow, f1 * 1.4f * (1 - percent * 0.12f));
        ViewHelper.setScaleY(iv_shadow, f1 * 1.85f * (1 - percent * 0.12f));
    }
    getBackground().setColorFilter(
            evaluate(percent, Color.BLACK, Color.TRANSPARENT),
            Mode.SRC_OVER);
}
 
Example 2
Project: GitHub   File: ProductTour2Activity.java   View Source Code Vote up 5 votes
@Override
public void transformPage(View page, float position) {
    int pageWidth = page.getWidth();
 
    View backgroundView = page.findViewById(R.id.welcome_fragment);
    View text_head= page.findViewById(R.id.heading);
    View text_content = page.findViewById(R.id.content);

    if(0 <= position && position < 1){
        ViewHelper.setTranslationX(page,pageWidth * -position);
    }
    if(-1 < position && position < 0){
        ViewHelper.setTranslationX(page,pageWidth * -position);
    }
 
    if(position <= -1.0f || position >= 1.0f) {
    } else if( position == 0.0f ) {
    } else {
        if(backgroundView != null) {
            ViewHelper.setAlpha(backgroundView,1.0f - Math.abs(position));

        }
 
        if (text_head != null) {
            ViewHelper.setTranslationX(text_head,pageWidth * position);
            ViewHelper.setAlpha(text_head,1.0f - Math.abs(position));
        }
        
        if (text_content != null) {
            ViewHelper.setTranslationX(text_content,pageWidth * position);
            ViewHelper.setAlpha(text_content,1.0f - Math.abs(position));
        }
    }
}
 
Example 3
Project: TestChat   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
    public void onCloseMenu() {
//                当侧滑完全关闭的时候调用
        if (ViewHelper.getAlpha(bg) != 0) {
            ViewHelper.setAlpha(bg, 0);
        }
        if (ViewHelper.getAlpha(icon_1) != 1) {
            ViewHelper.setAlpha(icon_1, 1);
        }
    }
 
Example 4
Project: TestChat   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public void onOpenMenu() {
    if (ViewHelper.getAlpha(bg) != 1) {
        ViewHelper.setAlpha(bg, 1);
    }
    if (ViewHelper.getAlpha(icon_1) != 0) {
        ViewHelper.setAlpha(icon_1, 0);
    }
    //                当侧滑完全打开的时候调用
}
 
Example 5
Project: Hotspot-master-devp   File: PagerSlidingTabStrip.java   View Source Code Vote up 5 votes
@Override
public void onPageSelected(int position) {
    selectedPosition = position;
    //set old view statue
    ViewHelper.setAlpha(tabViews.get(oldPosition).get("normal"), 1);
    ViewHelper.setAlpha(tabViews.get(oldPosition).get("selected"), 0);
    if(oldPosition<tabsContainer.getChildCount()) {
        View v_old = tabsContainer.getChildAt(oldPosition);
        ViewHelper.setPivotX(v_old, v_old.getMeasuredWidth() * 0.5f);
        ViewHelper.setPivotY(v_old, v_old.getMeasuredHeight() * 0.5f);
        ViewHelper.setScaleX(v_old, 1f);
        ViewHelper.setScaleY(v_old, 1f);
    }

    //set new view statue
    ViewHelper.setAlpha(tabViews.get(position).get("normal"), 0);
    ViewHelper.setAlpha(tabViews.get(position).get("selected"), 1);

    if(position<tabsContainer.getChildCount()) {
        View v_new = tabsContainer.getChildAt(position);
        ViewHelper.setPivotX(v_new, v_new.getMeasuredWidth() * 0.5f);
        ViewHelper.setPivotY(v_new, v_new.getMeasuredHeight() * 0.5f);
        ViewHelper.setScaleX(v_new, 1 + zoomMax);
        ViewHelper.setScaleY(v_new, 1 + zoomMax);
    }

    if (delegatePageListener != null) {
        delegatePageListener.onPageSelected(position);
    }
    oldPosition = selectedPosition;
}
 
Example 6
Project: JewelryUI   File: JazzyViewPager.java   View Source Code Vote up 5 votes
protected void animateFade(View left, View right, float positionOffset) {
		//Log.e(TAG, "positionOffset: " + String.valueOf(positionOffset));
//		if (left != null) {
//			ViewHelper.setAlpha(left, 1-positionOffset);
//		}
		if (right != null) {
			ViewHelper.setAlpha(right, positionOffset);
		}
	}
 
Example 7
Project: Widgets   File: SlideLayout.java   View Source Code Vote up 5 votes
/**
     * 伴随动画
     *
     * @return 当前滑动的比例
     */
    private float animViews() {
        float percent = mSlideDx * 1.0f / mSlideRang;

        // 左面板: 缩放动画, 平移动画, 透明度动画
//        ViewHelper.setScaleX(mLeftView, 0.4f + 0.4f * percent);
//        ViewHelper.setScaleY(mLeftView, 0.4f + 0.4f * percent);
        ViewHelper.setScaleX(mLeftView, evaluate(percent, 0.4f, 1.0f));
        ViewHelper.setScaleY(mLeftView, evaluate(percent, 0.4f, 1.0f));
        // 平移动画: -mWidth / 2.0f -> 0.0f
        ViewHelper.setTranslationX(mLeftView, evaluate(percent, -mWidth / 2.0f, 0));
        // 透明度: 0.4 -> 1.0f
        ViewHelper.setAlpha(mLeftView, evaluate(percent, 0.4f, 1.0f));

        // 主面板: 缩放动画  1.0f -> 0.8f
        ViewHelper.setScaleX(mMainView, evaluate(percent, 1.0f, 0.8f));
        ViewHelper.setScaleY(mMainView, evaluate(percent, 1.0f, 0.8f));

        // 透明度: 1.0 -> 0.6f
        if (mMainAlphaEnable) {
            ViewHelper.setAlpha(mMainView, evaluate(percent, 1.0f, 0.6f));
        }

        // 整个控件的背景动画: 亮度变化 (颜色变化)
        if (null != getBackground()) {
            getBackground().setColorFilter((Integer) evaluateColor(percent, mAlphaColor, Color.TRANSPARENT), PorterDuff.Mode.SRC_OVER);
        }

        return percent;
    }
 
Example 8
Project: JazzyViewPager   File: JazzyViewPager.java   View Source Code Vote up 5 votes
protected void animateFade(View left, View right, float positionOffset) {
	if (left != null) {
		ViewHelper.setAlpha(left, 1-positionOffset);
	}
	if (right != null) {
		ViewHelper.setAlpha(right, positionOffset);
	}
}
 
Example 9
Project: Sega   File: DepthPageTransformer.java   View Source Code Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
	if (position <= 0f) {
           ViewHelper.setTranslationX(view,0f);
           ViewHelper.setScaleX(view,1f);
           ViewHelper.setScaleY(view,1f);
	} else if (position <= 1f) {
		final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
           ViewHelper.setAlpha(view,1-position);
           ViewHelper.setPivotY(view,0.5f * view.getHeight());
           ViewHelper.setTranslationX(view,view.getWidth() * - position);
           ViewHelper.setScaleX(view,scaleFactor);
           ViewHelper.setScaleY(view,scaleFactor);
	}
}
 
Example 10
Project: Sega   File: ZoomOutTransformer.java   View Source Code Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
    final float scale = 1f + Math.abs(position);
    ViewHelper.setScaleX(view,scale);
    ViewHelper.setScaleY(view,scale);
    ViewHelper.setPivotX(view,view.getWidth() * 0.5f);
    ViewHelper.setPivotY(view,view.getWidth() * 0.5f);
    ViewHelper.setAlpha(view,position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
    if(position < -0.9){
        //-0.9 to prevent a small bug
        ViewHelper.setTranslationX(view,view.getWidth() * position);
    }
}
 
Example 11
Project: androidgithub   File: PTSlidingMenu.java   View Source Code Vote up 5 votes
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    super.onScrollChanged(l, t, oldl, oldt);
    float scale = l * 1.0f / mMenuWidth;

    ViewHelper.setAlpha(mMenu, 0.6f + 0.4f * (1 - scale));
    ViewHelper.setTranslationX(mMenu, mMenuWidth * scale * 0.7f);

}
 
Example 12
Project: Sega   File: FlipHorizontalTransformer.java   View Source Code Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
	final float rotation = 180f * position;
       ViewHelper.setAlpha(view,rotation > 90f || rotation < -90f ? 0 : 1);
       ViewHelper.setPivotY(view,view.getHeight()*0.5f);
	ViewHelper.setPivotX(view,view.getWidth() * 0.5f);
	ViewHelper.setRotationY(view,rotation);
}
 
Example 13
Project: Sega   File: ZoomOutSlideTransformer.java   View Source Code Vote up 5 votes
@Override
protected void onTransform(View view, float position) {
	if (position >= -1 || position <= 1) {
		// Modify the default slide transition to shrink the page as well
		final float height = view.getHeight();
		final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
		final float vertMargin = height * (1 - scaleFactor) / 2;
		final float horzMargin = view.getWidth() * (1 - scaleFactor) / 2;

           // Center vertically
           ViewHelper.setPivotY(view,0.5f * height);


		if (position < 0) {
               ViewHelper.setTranslationX(view,horzMargin - vertMargin / 2);
		} else {
               ViewHelper.setTranslationX(view,-horzMargin + vertMargin / 2);
		}

		// Scale the page down (between MIN_SCALE and 1)
		ViewHelper.setScaleX(view,scaleFactor);
           ViewHelper.setScaleY(view,scaleFactor);

		// Fade the page relative to its size.
           ViewHelper.setAlpha(view,MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
	}
}
 
Example 14
Project: GongXianSheng   File: BaseViewAnimator.java   View Source Code Vote up 5 votes
/**
 * reset the view to default status
 *
 * @param target
 */
public void reset(View target) {
	ViewHelper.setAlpha(target, 1);
	ViewHelper.setScaleX(target, 1);
	ViewHelper.setScaleY(target, 1);
	ViewHelper.setTranslationX(target, 0);
	ViewHelper.setTranslationY(target, 0);
	ViewHelper.setRotation(target, 0);
	ViewHelper.setRotationY(target, 0);
	ViewHelper.setRotationX(target, 0);
	ViewHelper.setPivotX(target, target.getMeasuredWidth() / 2.0f);
	ViewHelper.setPivotY(target, target.getMeasuredHeight() / 2.0f);
}
 
Example 15
Project: MyAnimeViewer   File: BaseItemAnimator.java   View Source Code Vote up 5 votes
public static void clear(View v) {
    ViewHelper.setAlpha(v, 1);
    ViewHelper.setScaleY(v, 1);
    ViewHelper.setScaleX(v, 1);
    ViewHelper.setTranslationY(v, 0);
    ViewHelper.setTranslationX(v, 0);
    ViewHelper.setRotation(v, 0);
    ViewHelper.setRotationY(v, 0);
    ViewHelper.setRotationX(v, 0);
    // @TODO https://code.google.com/p/android/issues/detail?id=80863
    //        ViewHelper.setPivotY(v, v.getMeasuredHeight() / 2);
    v.setPivotY(v.getMeasuredHeight() / 2);
    ViewHelper.setPivotX(v, v.getMeasuredWidth() / 2);
    ViewPropertyAnimator.animate(v).setInterpolator(null);
}
 
Example 16
Project: MenuSet   File: MenuAdapter.java   View Source Code Vote up 4 votes
/**
 * Set starting params to text animations
 */
private void resetTextAnimation(View v) {
    ViewHelper.setAlpha(v, !mIsMenuOpen ? 0 : 1);
    ViewHelper.setTranslationX(v, !mIsMenuOpen ? mMenuItemSize : 0);
}
 
Example 17
Project: WiFiSDCryptoLocker   File: CrossfadePageTransformer.java   View Source Code Vote up 4 votes
private void setAlpha(View view, float alpha) {
    if (view == null) {
        return;
    }
    ViewHelper.setAlpha(view, alpha);
}
 
Example 18
Project: TestChat   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
public void onDrag(View view, float delta) {
    ViewHelper.setAlpha(bg, delta);
    ViewHelper.setAlpha(icon_1, (1 - delta));
}
 
Example 19
Project: Hotspot-master-devp   File: PagerSlidingTabStrip.java   View Source Code Vote up 4 votes
private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        FrameLayout frameLayout = (FrameLayout) tabsContainer.getChildAt(i);
        frameLayout.setBackgroundResource(tabBackgroundResId);

        for (int j = 0; j < frameLayout.getChildCount(); j++) {
            View v = frameLayout.getChildAt(j);
            if (v instanceof TextView) {
                TextView tab = (TextView) v;
                tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
                tab.setTypeface(tabTypeface, tabTypefaceStyle);
                tab.setPadding(tabPadding, 0, tabPadding, 0);
                if (j == 0) {
                    tab.setTextColor(tabTextColor);
                } else {
                    tab.setTextColor(selectedTabTextColor);
                }
                ViewHelper.setAlpha(tabViews.get(i).get("normal"), 1);
                ViewHelper.setAlpha(tabViews.get(i).get("selected"), 0);

                //set normal  Scale
                ViewHelper.setPivotX(frameLayout, frameLayout.getMeasuredWidth() * 0.5f);
                ViewHelper.setPivotY(frameLayout, frameLayout.getMeasuredHeight() * 0.5f);
                ViewHelper.setScaleX(frameLayout, 1f);
                ViewHelper.setScaleY(frameLayout, 1f);

                // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
                // pre-ICS-build
                if (textAllCaps) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                        tab.setAllCaps(true);
                    } else {
                        tab.setText(tab.getText().toString().toUpperCase(locale));
                    }
                }
                if (i == selectedPosition) {
                    ViewHelper.setAlpha(tabViews.get(i).get("normal"), 0);
                    ViewHelper.setAlpha(tabViews.get(i).get("selected"), 1);

                    //set select  Scale
                    ViewHelper.setPivotX(frameLayout, frameLayout.getMeasuredWidth() * 0.5f);
                    ViewHelper.setPivotY(frameLayout, frameLayout.getMeasuredHeight() * 0.5f);
                    ViewHelper.setScaleX(frameLayout, 1 + zoomMax);
                    ViewHelper.setScaleY(frameLayout, 1 + zoomMax);
                }
            }
        }
    }
}
 
Example 20
Project: Sega   File: BaseTransformer.java   View Source Code Vote up 4 votes
/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)} is called.
 *
 * @param view
 * @param position
 */
protected void onPreTransform(View view, float position) {
    final float width = view.getWidth();

    ViewHelper.setRotationX(view,0);
    ViewHelper.setRotationY(view,0);
    ViewHelper.setRotation(view,0);
    ViewHelper.setScaleX(view,1);
    ViewHelper.setScaleY(view,1);
    ViewHelper.setPivotX(view,0);
    ViewHelper.setPivotY(view,0);
    ViewHelper.setTranslationY(view,0);
    ViewHelper.setTranslationX(view,isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        ViewHelper.setAlpha(view,position <= -1f || position >= 1f ? 0f : 1f);
    } else {
        ViewHelper.setAlpha(view,1f);
    }
    if(mCustomAnimationInterface != null){
        if(!h.containsKey(view) || h.get(view).size() == 1){
            if(position > -1 && position < 1){
                if(h.get(view) == null){
                    h.put(view,new ArrayList<Float>());
                }
                h.get(view).add(position);
                if(h.get(view).size() == 2){
                    float zero = h.get(view).get(0);
                    float cha = h.get(view).get(1) - h.get(view).get(0);
                    if(zero > 0){
                        if(cha > -1 && cha < 0){
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }else{
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }
                    }else{
                        if(cha > -1 && cha < 0){
                            //out
                            mCustomAnimationInterface.onPrepareCurrentItemLeaveScreen(view);
                        }else{
                            //in
                            mCustomAnimationInterface.onPrepareNextItemShowInScreen(view);
                        }
                    }
                }
            }
        }
    }
}