android.widget.ImageView#setAlpha ( )源码实例Demo

下面列出了android.widget.ImageView#setAlpha ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LLApp   文件: KenBurnsView.java
private void swapImage() {
    Log.d(TAG, "swapImage active=" + mActiveImageIndex);
    if(mActiveImageIndex == -1) {
        mActiveImageIndex = 1;
        animate(mImageViews[mActiveImageIndex]);
        return;
    }

    int inactiveIndex = mActiveImageIndex;
    mActiveImageIndex = (1 + mActiveImageIndex) % mImageViews.length;
    Log.d(TAG, "new active=" + mActiveImageIndex);

    final ImageView activeImageView = mImageViews[mActiveImageIndex];
    activeImageView.setAlpha(0.0f);
    ImageView inactiveImageView = mImageViews[inactiveIndex];

    animate(activeImageView);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(mFadeInOutMs);
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(inactiveImageView, "alpha", 1.0f, 0.0f),
            ObjectAnimator.ofFloat(activeImageView, "alpha", 0.0f, 1.0f)
    );
    animatorSet.start();
}
 
源代码2 项目: Travel-Mate   文件: CityImageSliderAdapter.java
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    ImageView imageView = new ImageView(mContext);
    //display default city image if no image is present in array
    if (mImagesArray.size() == 0) {
        Picasso.with(mContext).load(R.drawable.placeholder_image)
                .error(R.drawable.placeholder_image).fit().centerCrop().into(imageView);
    }
    Picasso.with(mContext).load(mImagesArray.get(position))
            .error(R.drawable.placeholder_image).fit().centerCrop().into(imageView);
    container.addView(imageView);
    imageView.setOnClickListener(v -> {
        Intent fullScreenIntent = FullScreenImage.getStartIntent(mContext,
                mImagesArray.get(position), mCityName);
        mContext.startActivity(fullScreenIntent);
    });
    imageView.setBackgroundColor(Color.TRANSPARENT);
    imageView.setAlpha(0.6f);
    return imageView;
}
 
源代码3 项目: BlurTestAndroid   文件: TableFixHeaders.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressWarnings("deprecation")
private void setAlpha(ImageView imageView, float alpha) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		imageView.setAlpha(alpha);
	} else {
		imageView.setAlpha(Math.round(alpha * 255));
	}
}
 
源代码4 项目: FireFiles   文件: IconHelper.java
/**
 * Load thumbnails for a directory list item.
 * @param uri The URI for the file being represented.
 * @param mimeType The mime type of the file being represented.
 * @param docFlags Flags for the file being represented.
 * @param iconThumb The itemview's thumbnail icon.
 * @param iconMimeBackground
 * @return
 */
public void loadThumbnail(Uri uri, String path, String mimeType, int docFlags, int docIcon,
                          ImageView iconMime, ImageView iconThumb, View iconMimeBackground) {
    boolean cacheHit = false;

    final String docAuthority = uri.getAuthority();
    String docId = DocumentsContract.getDocumentId(uri);
    final boolean supportsThumbnail = (docFlags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0;
    final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mimeType);
    final boolean showThumbnail = supportsThumbnail && allowThumbnail && mThumbnailsEnabled;
    if (showThumbnail) {
        final Bitmap cachedResult = mCache.get(uri);
        if (cachedResult != null) {
            iconThumb.setImageBitmap(cachedResult);
            cacheHit = true;
            iconMimeBackground.setVisibility(View.GONE);
        } else {
            iconThumb.setImageDrawable(null);
            final LoaderTask task = new LoaderTask(uri, path, mimeType, mThumbSize, iconThumb,
                    iconMime, iconMimeBackground);
            iconThumb.setTag(task);
            ProviderExecutor.forAuthority(docAuthority).execute(task);
        }
    }

    if (cacheHit) {
        iconMime.setImageDrawable(null);
        iconMime.setAlpha(0f);
        iconThumb.setAlpha(1f);
    } else {
        // Add a mime icon if the thumbnail is being loaded in the background.
        iconThumb.setImageDrawable(null);
        iconMime.setImageDrawable(getDocumentIcon(mContext, docAuthority, docId, mimeType, docIcon));
        iconMime.setAlpha(1f);
        iconThumb.setAlpha(0f);
    }
}
 
源代码5 项目: MicroReader   文件: ImageLoader.java
public static void loadImage(Context context, String url, ImageView imageView) {
    if (Config.isNight) {
        imageView.setAlpha(0.2f);
        imageView.setBackgroundColor(Color.BLACK);
    }
    Glide.with(context).load(url).into(imageView);
}
 
/**
 * Update small notification icons when there is new notification coming, and the
 * Activity is in foreground.
 */
private void updateNotificationIcons() {

    if (mNotificationsContainer.getVisibility() != View.VISIBLE) {
        mNotificationsContainer.setVisibility(View.VISIBLE);
    }

    NotificationHub notificationHub = NotificationHub.getInstance();

    int iconSize = getResources().getDimensionPixelSize(R.dimen.small_notification_icon_size);
    int padding = getResources().getDimensionPixelSize(R.dimen.small_notification_icon_padding);

    final StatusBarNotification n = notificationHub.getCurrentNotification();
    ImageView icon = new ImageView(this);
    icon.setAlpha(NotificationPeek.ICON_LOW_OPACITY);

    icon.setPadding(padding, 0, padding, 0);
    icon.setImageDrawable(NotificationPeekViewUtils.getIconFromResource(this, n));
    icon.setTag(n);

    restoreFirstIconVisibility();

    int oldIndex = getOldIconViewIndex(notificationHub);

    if (oldIndex >= 0) {
        mNotificationsContainer.removeViewAt(oldIndex);
    }

    mNotificationsContainer.addView(icon);
    LinearLayout.LayoutParams linearLayoutParams =
            new LinearLayout.LayoutParams(iconSize, iconSize);

    // Wrap LayoutParams to GridLayout.LayoutParams.
    GridLayout.LayoutParams gridLayoutParams = new GridLayout.LayoutParams(linearLayoutParams);
    icon.setLayoutParams(gridLayoutParams);
}
 
源代码7 项目: SchoolQuest   文件: GameActivity.java
public void enableCancelButton() {
    ImageView cancelButton = findViewById(R.id.cancel_button);
    ImageView lessonCancelButton = findViewById(R.id.lesson_c_cancel_button);

    cancelButton.setAlpha(1f);
    cancelButton.setEnabled(true);

    lessonCancelButton.setAlpha(1f);
    lessonCancelButton.setEnabled(true);
}
 
源代码8 项目: BubbleActions   文件: BubbleActionOverlay.java
BubbleActionOverlay(Context context) {
    super(context);
    contentClipRect = new RectF();
    dragShadowBuilder = new DragShadowBuilder();
    dragData = DragUtils.getClipData();

    LayoutInflater inflater = LayoutInflater.from(context);
    bubbleActionIndicator = (ImageView) inflater.inflate(R.layout.bubble_actions_indicator, this, false);
    bubbleActionIndicator.setAlpha(0f);
    addView(bubbleActionIndicator, -1);

    interpolator = new OvershootInterpolator(OVERSHOOT_TENSION);

    int transparentBackgroundColor = ContextCompat.getColor(context, R.color.bubble_actions_background_transparent);
    int darkenedBackgroundColor = ContextCompat.getColor(context, R.color.bubble_actions_background_darkened);
    setBackgroundColor(transparentBackgroundColor);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        backgroundAnimator = ObjectAnimator.ofArgb(this, "backgroundColor", transparentBackgroundColor, darkenedBackgroundColor);
    } else {
        backgroundAnimator = ObjectAnimator.ofObject(this, "backgroundColor", new BackgroundAlphaTypeEvaluator(), transparentBackgroundColor, darkenedBackgroundColor);
    }

    animationDuration = BASE_ANIMATION_DURATION;

    bubbleDimension = (int) getResources().getDimension(R.dimen.bubble_actions_indicator_dimension);
    startActionDistanceFromCenter = getResources().getDimension(R.dimen.bubble_actions_start_distance);
    stopActionDistanceFromCenter = getResources().getDimension(R.dimen.bubble_actions_stop_distance);

    for (int i = 0; i < MAX_ACTIONS; i++) {
        BubbleView itemView = new BubbleView(getContext());
        itemView.setVisibility(INVISIBLE);
        itemView.setAlpha(0f);
        addView(itemView, -1, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    }
}
 
源代码9 项目: TestChat   文件: MainActivity.java
@Override
public void initView() {
    LogUtil.e("initMain123");
    RecentFragment recentFragment = new RecentFragment();
    ContactsFragment contactsFragment = new ContactsFragment();
    InvitationFragment invitationFragment = new InvitationFragment();
    ShareMessageFragment shareMessageFragment = new ShareMessageFragment();
    mFragments[0] = recentFragment;
    mFragments[1] = contactsFragment;
    mFragments[2] = invitationFragment;
    mFragments[3] = shareMessageFragment;
    container = (DragLayout) findViewById(R.id.drag_container);
    menuDisplay = (RecyclerView) findViewById(R.id.rev_menu_display);
    nick = (TextView) findViewById(R.id.tv_menu_nick);
    signature = (TextView) findViewById(R.id.tv_menu_signature);
    avatar = (RoundAngleImageView) findViewById(R.id.riv_menu_avatar);
    headLayout = (RelativeLayout) findViewById(R.id.rl_menu_head_layout);
    bg = (ImageView) findViewById(R.id.iv_main_bg);
    net = (TextView) findViewById(R.id.tv_main_net);
    weatherCity = (TextView) findViewById(R.id.tv_menu_weather_city);
    weatherTemperature = (TextView) findViewById(R.id.tv_menu_weather_temperature);
    bottomLayout = (LinearLayout) findViewById(R.id.ll_menu_bottom_container);
    bg.setAlpha((float) 0.0);
    menuDisplay.setLayoutManager(new LinearLayoutManager(this));
    menuDisplay.setHasFixedSize(true);
    menuDisplay.setItemAnimator(new DefaultItemAnimator());
    container.setListener(this);
    headLayout.setOnClickListener(this);
    net.setOnClickListener(this);
    bottomLayout.setOnClickListener(this);
    initActionBarView();
}
 
源代码10 项目: ghwatch   文件: ImageLoader.java
protected void showImageInView(ImageView iv, Bitmap bitmap, boolean animate) {
  iv.clearAnimation();
  if (animate)
    iv.setAlpha(0f);
  iv.setImageBitmap(bitmap);
  setProgressBarVisibility(iv, false);
  if (animate)
    iv.animate().alpha(1f).setDuration(200).start();
}
 
源代码11 项目: DistroHopper   文件: RunningAppLauncher.java
@Override
protected void iconChanged ()
{
	if (! this.isInEditMode ())
	{
		ImageView imgIcon = (ImageView) this.findViewById (R.id.imgIcon);
		imgIcon.setImageDrawable (this.getIcon ().getDrawable ());

		LinearLayout llBackground = (LinearLayout) this.findViewById (R.id.llBackground);
		if (llBackground != null && (! this.isSpecial ()))
			this.colourChanged ();
		
		imgIcon.setAlpha (0.9F);
	}
}
 
源代码12 项目: iBeebo   文件: LocalWorker.java
private void playImageViewAnimation(final ImageView view, final Bitmap bitmap) {

        view.setImageBitmap(bitmap);
        resetProgressBarStatues();
        view.setAlpha(0f);
        view.animate().alpha(1.0f).setDuration(500).setListener(new LayerEnablingAnimatorListener(view, null));
        view.setTag(getUrl());

    }
 
源代码13 项目: ECardFlow   文件: BlurAnimMode.java
@Override
public void transformPage(ImageView ivBg, float position, int direction) {
    float mFraction = (float) Math.cos(2 * Math.PI * position);
    if (mFraction < 0)
        mFraction = 0;
        ivBg.setAlpha(mFraction);
}
 
@Override
public void bindView(View view, Context context, Cursor cursor) {
    // Get the decoration for the current row
    Decoration decoration = mDecorationCursor.getDecoration();

    RelativeLayout itemLayout = (RelativeLayout) view.findViewById(R.id.listitem);

    // Set up the text view
    ImageView itemImageView = (ImageView) view.findViewById(R.id.item_image);
    TextView decorationNameTextView = (TextView) view.findViewById(R.id.item);
    TextView skill1TextView = (TextView) view.findViewById(R.id.skill1);
    TextView skill1amtTextView = (TextView) view.findViewById(R.id.skill1_amt);
    TextView skill2TextView = (TextView) view.findViewById(R.id.skill2);
    TextView skill2amtTextView = (TextView) view.findViewById(R.id.skill2_amt);

    String decorationNameText = decoration.getName();
    String skill1Text = decoration.getSkill1Name();
    String skill1amtText = "" + decoration.getSkill1Point();
    String skill2Text = decoration.getSkill2Name();
    String skill2amtText = "";
    if (decoration.getSkill2Point() != 0) {
        skill2amtText = skill2amtText + decoration.getSkill2Point();
    }

    Drawable i = null;
    String cellImage = "icons_items/" + decoration.getFileLocation();
    try {
        i = Drawable.createFromStream(
                context.getAssets().open(cellImage), null);
    } catch (IOException e) {
        e.printStackTrace();
    }

    itemImageView.setImageDrawable(i);

    decorationNameTextView.setText(decorationNameText);
    skill1TextView.setText(skill1Text);
    skill1amtTextView.setText(skill1amtText);

    skill2TextView.setVisibility(View.GONE);
    skill2amtTextView.setVisibility(View.GONE);

    if (!skill2amtText.equals("")) {
        skill2TextView.setText(skill2Text);
        skill2amtTextView.setText(skill2amtText);
        skill2TextView.setVisibility(View.VISIBLE);
        skill2amtTextView.setVisibility(View.VISIBLE);
    }

    itemLayout.setTag(decoration.getId());

    if (fromAsb) {
        boolean fitsInArmor = (decoration.getNumSlots() <= maxSlots);
        view.setEnabled(fitsInArmor);

        // Set the jewel image to be translucent if disabled
        // TODO: If a way to use alpha with style selectors exist, use that instead
        itemImageView.setAlpha((fitsInArmor) ? 1.0f : 0.5f);

        if (fitsInArmor) {
            itemLayout.setOnClickListener(new DecorationClickListener(context, decoration.getId(), true, activity));
        }
    }
    else {
        itemLayout.setOnClickListener(new DecorationClickListener(context, decoration.getId()));
    }
}
 
源代码15 项目: KenBurnsView   文件: KenBurnsView.java
private void forceSwapImage() {

        if (mImageViews.length <= 0) {
            return;
        }

        if (mActiveImageIndex == -1) {
            mActiveImageIndex = FIRST_IMAGE_VIEW_INDEX;
            animate(mImageViews[mActiveImageIndex]);
            return;
        }

        int inactiveIndex = mActiveImageIndex;

        if (mPreviousPosition >= mPosition) {
            mActiveImageIndex = swapDirection(mActiveImageIndex, true);
        } else {
            mActiveImageIndex = swapDirection(mActiveImageIndex, false);
        }

        if (mPreviousPosition == 0 && mPosition == getSizeByLoadType() - 1) {
            mActiveImageIndex = swapDirection(mActiveImageIndex, true);
        }

        if (mPreviousPosition == getSizeByLoadType() - 1 && mPosition == 0) {
            mActiveImageIndex = swapDirection(mActiveImageIndex, false);
        }

        if (mActiveImageIndex >= mImageViews.length) {
            mActiveImageIndex = FIRST_IMAGE_VIEW_INDEX;
        }

        final ImageView activeImageView = mImageViews[mActiveImageIndex];
        loadImages(mPosition, mActiveImageIndex);
        activeImageView.setAlpha(0.0f);

        ImageView inactiveImageView = mImageViews[inactiveIndex];

        animate(activeImageView);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(mFadeInOutMs);
        animatorSet.playTogether(
                ObjectAnimator.ofFloat(inactiveImageView, PROPERTY_ALPHA, 1.0f, 0.0f),
                ObjectAnimator.ofFloat(activeImageView, PROPERTY_ALPHA, 0.0f, 1.0f)
        );
        animatorSet.start();
    }
 
源代码16 项目: SchoolQuest   文件: GameActivity.java
public void enableSkipButton() {
    ImageView skipButton = findViewById(R.id.skip_button);

    skipButton.setAlpha(1f);
    skipButton.setEnabled(true);
}
 
源代码17 项目: iBeebo   文件: TimeLineBitmapDownloader.java
private void displayImageView(final ImageView view, final String urlKey, final FileLocationMethod method,
                              boolean isFling, boolean isMultiPictures) {
    view.clearAnimation();

    if (!shouldReloadPicture(view, urlKey)) {
        return;
    }

    final Bitmap bitmap = getBitmapFromMemCache(urlKey);
    if (bitmap != null) {
        view.setImageBitmap(bitmap);
        view.setTag(urlKey);
        if (view.getAlpha() != 1.0f) {
            view.setAlpha(1.0f);
        }
        cancelPotentialDownload(urlKey, view);
    } else {

        if (isFling) {
            view.setImageResource(defaultPictureResId);
            return;
        }

        if (!cancelPotentialDownload(urlKey, view)) {
            return;
        }

        final LocalOrNetworkChooseWorker newTask = new LocalOrNetworkChooseWorker(view, urlKey, method, isMultiPictures);
        PictureBitmapDrawable downloadedDrawable = new PictureBitmapDrawable(newTask);
        view.setImageDrawable(downloadedDrawable);

        // listview fast scroll performance
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

                if (getBitmapDownloaderTask(view) == newTask) {
                    newTask.executeOnNormal();
                }
                return;

            }
        }, 400);

    }

}
 
源代码18 项目: KenBurnsView   文件: KenBurnsView.java
private void autoSwapImage() {

        if (mImageViews.length <= 0) {
            return;
        }

        if (mActiveImageIndex == -1) {
            mActiveImageIndex = FIRST_IMAGE_VIEW_INDEX;
            animate(mImageViews[mActiveImageIndex]);
            return;
        }

        int inactiveIndex = mActiveImageIndex;
        mActiveImageIndex = (1 + mActiveImageIndex);

        if (mActiveImageIndex >= mImageViews.length) {
            mActiveImageIndex = FIRST_IMAGE_VIEW_INDEX;
        }

        if (mLoopViewPager != null) {
            mPosition++;

            if (mPosition >= getSizeByLoadType()) {
                mPosition = 0;
            }

            mLoopViewPager.setCurrentItemAfterCancelListener(mPosition, false);
        }

        final ImageView activeImageView = mImageViews[mActiveImageIndex];
        loadImages(mPosition, mActiveImageIndex);
        activeImageView.setAlpha(0.0f);

        ImageView inactiveImageView = mImageViews[inactiveIndex];

        animate(activeImageView);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(mFadeInOutMs);
        animatorSet.playTogether(
                ObjectAnimator.ofFloat(inactiveImageView, PROPERTY_ALPHA, 1.0f, 0.0f),
                ObjectAnimator.ofFloat(activeImageView, PROPERTY_ALPHA, 0.0f, 1.0f)
        );
        animatorSet.start();
    }
 
源代码19 项目: utexas-utilities   文件: Utility.java
public static void setImageAlpha(ImageView iv, int alpha) {
    // imageView#setImageAlpha method seems to be broken on 4.x, so use the View.setAlpha
    // method instead.
    iv.setAlpha(alpha/255f);
}
 
源代码20 项目: RichEditText   文件: RichEditText.java
private void letImageViewOn(ImageView iv) {
    iv.setAlpha(1.0f);

}