本文整理汇总了Java中com.nineoldandroids.view.ViewHelper.setAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java ViewHelper.setAlpha方法的具体用法?Java ViewHelper.setAlpha怎么用?Java ViewHelper.setAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nineoldandroids.view.ViewHelper
的用法示例。
在下文中一共展示了ViewHelper.setAlpha方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: animateView
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
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);
}
示例2: transformPage
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@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));
}
}
}
示例3: onCloseMenu
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@Override
public void onCloseMenu() {
// 当侧滑完全关闭的时候调用
if (ViewHelper.getAlpha(bg) != 0) {
ViewHelper.setAlpha(bg, 0);
}
if (ViewHelper.getAlpha(icon_1) != 1) {
ViewHelper.setAlpha(icon_1, 1);
}
}
示例4: onOpenMenu
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@Override
public void onOpenMenu() {
if (ViewHelper.getAlpha(bg) != 1) {
ViewHelper.setAlpha(bg, 1);
}
if (ViewHelper.getAlpha(icon_1) != 0) {
ViewHelper.setAlpha(icon_1, 0);
}
// 当侧滑完全打开的时候调用
}
示例5: onPageSelected
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@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;
}
示例6: animateFade
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
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);
}
}
示例7: animViews
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
/**
* 伴随动画
*
* @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;
}
示例8: animateFade
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
protected void animateFade(View left, View right, float positionOffset) {
if (left != null) {
ViewHelper.setAlpha(left, 1-positionOffset);
}
if (right != null) {
ViewHelper.setAlpha(right, positionOffset);
}
}
示例9: onTransform
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@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);
}
}
示例10: onTransform
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@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);
}
}
示例11: onScrollChanged
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@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);
}
示例12: onTransform
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@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);
}
示例13: onTransform
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
@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));
}
}
示例14: reset
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
/**
* 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);
}
示例15: clear
import com.nineoldandroids.view.ViewHelper; //导入方法依赖的package包/类
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);
}