當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。