当前位置: 首页>>代码示例>>Java>>正文


Java View.setAlpha方法代码示例

本文整理汇总了Java中android.view.View.setAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java View.setAlpha方法的具体用法?Java View.setAlpha怎么用?Java View.setAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.setAlpha方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transformPage

import android.view.View; //导入方法依赖的package包/类
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();

    if (position <= 0) {
        // use the default slide transition when moving to the left page
        view.setAlpha(1);
        view.setTranslationX(0);

    } else if (position <= 1) {
        // fade the page out.
        view.setAlpha(1 - position);

        // add parallax effect
        view.setTranslationX(pageWidth * -position / 2);

    } else {
        // this page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:21,代码来源:ScreenShotsActivity.java

示例2: createAddSelectedTabLayoutListener

import android.view.View; //导入方法依赖的package包/类
/**
 * Creates and returns a layout listener, which allows to show a tab as the currently selected
 * one, once it view has been inflated.
 *
 * @param item
 *         The item, which corresponds to the tab, which has been added, as an instance of the
 *         class {@link AbstractItem}. The item may not be null
 * @return The listener, which has been created, as an instance of the type {@link
 * OnGlobalLayoutListener}. The listener may not be null
 */
@NonNull
private OnGlobalLayoutListener createAddSelectedTabLayoutListener(
        @NonNull final AbstractItem item) {
    return new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            View view = item.getView();
            FrameLayout.LayoutParams layoutParams =
                    (FrameLayout.LayoutParams) view.getLayoutParams();
            view.setAlpha(1f);
            getArithmetics().setPivot(Axis.DRAGGING_AXIS, item,
                    getArithmetics().getPivot(Axis.DRAGGING_AXIS, item, DragState.NONE));
            getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item,
                    getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, item, DragState.NONE));
            view.setX(layoutParams.leftMargin);
            view.setY(layoutParams.topMargin);
            getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 1);
            getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 1);
        }

    };
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:34,代码来源:PhoneTabSwitcherLayout.java

示例3: createRevealLayoutListener

import android.view.View; //导入方法依赖的package包/类
/**
 * Creates and returns a layout listener, which allows to start a reveal animation to add a tab,
 * once its view has been inflated.
 *
 * @param item
 *         The item, which corresponds to the tab, which should be added, as an instance of the
 *         class {@link AbstractItem}. The item may not be null
 * @param revealAnimation
 *         The reveal animation, which should be started, as an instance of the class {@link
 *         RevealAnimation}. The reveal animation may not be null
 * @return The listener, which has been created, as an instance of the type {@link
 * OnGlobalLayoutListener}. The listener may not be null
 */
@NonNull
private OnGlobalLayoutListener createRevealLayoutListener(@NonNull final AbstractItem item,
                                                          @NonNull final RevealAnimation revealAnimation) {
    return new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            View view = item.getView();
            float x = revealAnimation.getX();
            float y = revealAnimation.getY() + tabTitleContainerHeight;
            FrameLayout.LayoutParams layoutParams =
                    (FrameLayout.LayoutParams) view.getLayoutParams();
            view.setAlpha(1f);
            getArithmetics().setPivot(Axis.X_AXIS, item, x);
            getArithmetics().setPivot(Axis.Y_AXIS, item, y);
            view.setX(layoutParams.leftMargin);
            view.setY(layoutParams.topMargin);
            getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 0);
            getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 0);
            animateReveal(item, revealAnimation);
        }

    };
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:38,代码来源:PhoneTabSwitcherLayout.java

示例4: setUpBackdrop

import android.view.View; //导入方法依赖的package包/类
private void setUpBackdrop(View view) {
    Context context = view.getContext();

    ImageView imgBackdrop = (ImageView) view.findViewById(R.id.iv_movie_backdrop);
    View viewOverlay = view.findViewById(R.id.view_backdrop_overlay);
    TextView tvTitle = (TextView) view.findViewById(R.id.tv_movie_detail_title);

    Picasso.with(context)
            .load(R.mipmap.civil_war_backdrop)
            .transform(new GrayscaleTransformation(Picasso.with(context)))
            .into(imgBackdrop);

    imgBackdrop.setContentDescription(mTitle);
    viewOverlay.setAlpha((float) 0.8);
}
 
开发者ID:ramadani,项目名称:Pilem,代码行数:16,代码来源:MovieDetailFragment.java

示例5: onTransform

import android.view.View; //导入方法依赖的package包/类
protected void onTransform(View view, float position) {
    if (position >= -1.0f || position <= 1.0f) {
        float height = (float) view.getHeight();
        float scaleFactor = Math.max(MIN_SCALE, 1.0f - Math.abs(position));
        float vertMargin = ((1.0f - scaleFactor) * height) / 2.0f;
        float horzMargin = (((float) view.getWidth()) * (1.0f - scaleFactor)) / 2.0f;
        view.setPivotY(MIN_ALPHA * height);
        if (position < 0.0f) {
            view.setTranslationX(horzMargin - (vertMargin / 2.0f));
        } else {
            view.setTranslationX((-horzMargin) + (vertMargin / 2.0f));
        }
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);
        view.setAlpha((((scaleFactor - MIN_SCALE) / 0.14999998f) * MIN_ALPHA) + MIN_ALPHA);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:ZoomOutSlideTransformer.java

示例6: onTransform

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
	final float scale = 1f + Math.abs(position);
	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
	if(position == -1){
		view.setTranslationX(view.getWidth() * -1);
	}
}
 
开发者ID:aomari,项目名称:AndroidViewPagerRxJava,代码行数:13,代码来源:ZoomOutTranformer.java

示例7: onTransform

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
	final float rotation = -180f * position;

	view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setRotationX(rotation);
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:10,代码来源:FlipVerticalTransformer.java

示例8: onTransform

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
	final float scale = position < 0 ? position + 1f : Math.abs(1f - position);
	view.setScaleX(scale);
	view.setScaleY(scale);
	view.setPivotX(view.getWidth() * 0.5f);
	view.setPivotY(view.getHeight() * 0.5f);
	view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
}
 
开发者ID:maning0303,项目名称:MNImageBrowser,代码行数:10,代码来源:ZoomInTransformer.java

示例9: transformUnderlyingPage

import android.view.View; //导入方法依赖的package包/类
protected void transformUnderlyingPage(View page, float position, boolean enter) {
    page.setAlpha(1);
    page.setScaleX(1);
    page.setScaleY(1);
    page.setTranslationX(0);
    page.setTranslationY(0);
    // Avoid overdraw
    page.setVisibility(View.INVISIBLE);
}
 
开发者ID:alphater,项目名称:garras,代码行数:10,代码来源:PageAnimator.java

示例10: transformPage

import android.view.View; //导入方法依赖的package包/类
public void transformPage(View view, float position) {
    int pageWidth = view.getWidth();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);

    } else if (position <= 0) { // [-1,0]
        // Use the default slide transition when moving to the left page
        view.setAlpha(1);
        view.setTranslationX(0);
        view.setScaleX(1);
        view.setScaleY(1);
    } else if (position <= 1) { // (0,1]
        // Fade the page out.
        view.setAlpha(1 - position);

        // Counteract the default slide transition
        view.setTranslationX(pageWidth * -position);

        // Scale the page down (between MIN_SCALE and 1)
        float scaleFactor = MIN_SCALE
                + (1 - MIN_SCALE) * (1 - Math.abs(position));
        view.setScaleX(scaleFactor);
        view.setScaleY(scaleFactor);
    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
开发者ID:Nulltilus,项目名称:Appmatic-Android,代码行数:31,代码来源:DepthPageTransformer.java

示例11: transformPage

import android.view.View; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@Override
public void transformPage(View page, float position) {
    if (position < -1) {//页码完全不可见
        page.setAlpha(0);
    } else if (position < 0) {
        page.setAlpha(1 + position);
    } else if (position < 1) {
        page.setAlpha(1 - position);
    } else {
        page.setAlpha(0);
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:14,代码来源:FadeInOutPageTransformer.java

示例12: createHideSwitcherAnimationListener

import android.view.View; //导入方法依赖的package包/类
/**
 * Creates and returns an animation listener, which allows to inflate or remove the views, which
 * are used to visualize tabs, when an animation, which is used to hide the tab switcher,
 * has been finished.
 *
 * @return The animation listener, which has been created, as an instance of the type {@link
 * AnimatorListener}. The listener may not be null
 */
@NonNull
private AnimatorListener createHideSwitcherAnimationListener() {
    return new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(final Animator animation) {
            super.onAnimationEnd(animation);
            AbstractTabItemIterator iterator =
                    new TabItemIterator.Builder(getTabSwitcher(), viewRecycler).create();
            TabItem tabItem;

            while ((tabItem = iterator.next()) != null) {
                if (tabItem.getTab() == getModel().getSelectedTab()) {
                    Pair<View, Boolean> pair = viewRecycler.inflate(tabItem);
                    View view = pair.first;
                    FrameLayout.LayoutParams layoutParams =
                            (FrameLayout.LayoutParams) view.getLayoutParams();
                    view.setAlpha(1f);
                    getArithmetics().setScale(Axis.DRAGGING_AXIS, view, 1);
                    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, view, 1);
                    view.setX(layoutParams.leftMargin);
                    view.setY(layoutParams.topMargin);
                } else {
                    viewRecycler.remove(tabItem);
                }
            }

            viewRecycler.clearCache();
            recyclerAdapter.clearCachedPreviews();
            tabViewBottomMargin = -1;
        }

    };
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:43,代码来源:PhoneTabSwitcherLayout.java

示例13: onPressedChanged

import android.view.View; //导入方法依赖的package包/类
public void onPressedChanged(View target, boolean pressed) {
    if (mTarget.isEnabled()) {
        mTarget.setAlpha(mChangeAlphaWhenPress && pressed && target.isClickable()? mPressedAlpha : mNormalAlpha);
    } else {
        if (mChangeAlphaWhenDisable) {
            target.setAlpha(mDisabledAlpha);
        }
    }
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:10,代码来源:QMUIAlphaViewHelper.java

示例14: onTransform

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onTransform(View view, float position) {
	if (position <= 0f) {
		view.setTranslationX(0f);
		view.setScaleX(1f);
		view.setScaleY(1f);
	} else if (position <= 1f) {
		final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
		view.setAlpha(1 - position);
		view.setPivotY(0.5f * view.getHeight());
		view.setTranslationX(view.getWidth() * -position);
		view.setScaleX(scaleFactor);
		view.setScaleY(scaleFactor);
	}
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:16,代码来源:DepthPageTransformer.java

示例15: transformPageZoomOut

import android.view.View; //导入方法依赖的package包/类
private void transformPageZoomOut(View view, float position) {
    final float MIN_SCALE = 0.85f;
    final float MIN_ALPHA = 0.5f;

    int pageWidth = view.getWidth();
    int pageHeight = view.getHeight();

    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
        view.setAlpha(0);
    } else if (position <= 1) { // [-1,1]
        // Modify the default slide transition to shrink the page as well
        float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
        float verMargin = pageHeight * (1 - scaleFactor) / 2;
        float horzMargin = pageWidth * (1 - scaleFactor) / 2;
        if (position < 0) {
            view.setTranslationX(horzMargin - verMargin / 2);
        } else {
            view.setTranslationX(-horzMargin + verMargin / 2);
        }

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

        // Fade the page relative to its size.
        view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
        view.setAlpha(0);
    }
}
 
开发者ID:homeii,项目名称:GxIconAndroid,代码行数:33,代码来源:SimplePageTransformer.java


注:本文中的android.view.View.setAlpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。