Example usage for android.widget ImageView setImageAlpha

List of usage examples for android.widget ImageView setImageAlpha

Introduction

In this page you can find the example usage for android.widget ImageView setImageAlpha.

Prototype

@RemotableViewMethod
public void setImageAlpha(int alpha) 

Source Link

Document

Sets the alpha value that should be applied to the image.

Usage

From source file:Main.java

public static void setAlpha(ImageView imageView, int alpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        imageView.setImageAlpha(alpha);
    } else {//from   w ww.  j  a  v  a  2  s.  c  o  m
        imageView.setAlpha(alpha);
    }
}

From source file:Main.java

public static void setImageViewAlpha(ImageView imageView, int alpha) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        imageView.setAlpha(alpha);//from  w w w  .  ja  v a 2 s  . co m
    } else {
        imageView.setImageAlpha(alpha);
    }
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static void setAlpha(ImageView iv, int alpha) {
    if (iv.getBackground() != null) {
        iv.getBackground().setAlpha(alpha);
        return;/* ww w . j a  va2 s  .c om*/
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        iv.setImageAlpha(alpha);
    } else {
        iv.setAlpha(alpha);
    }
}

From source file:at.jclehner.rxdroid.DoseView.java

@TargetApi(16)
@SuppressWarnings("deprecation")
private static void setImageAlpha(ImageView image, int alpha) {
    if (Version.SDK_IS_JELLYBEAN_OR_NEWER)
        image.setImageAlpha(alpha);
    else/*from  ww w .j av a  2 s  .  c o m*/
        image.setAlpha(alpha);
}

From source file:org.jak_linux.dns66.main.StartFragment.java

public static void updateStatus(View rootView, int status) {
    Context context = rootView.getContext();
    TextView stateText = (TextView) rootView.findViewById(R.id.state_textview);
    ImageView startButton = (ImageView) rootView.findViewById(R.id.start_button);

    if (startButton == null || stateText == null)
        return;/*from   w  ww .j  a  v a  2  s.c o  m*/

    stateText.setText(rootView.getContext().getString(AdVpnService.vpnStatusToTextId(status)));

    startButton.getDrawable().setTintList(null);
    switch (status) {
    case AdVpnService.VPN_STATUS_RECONNECTING:
    case AdVpnService.VPN_STATUS_STARTING:
    case AdVpnService.VPN_STATUS_STOPPING:
        startButton.setImageAlpha(128);
        break;
    case AdVpnService.VPN_STATUS_STOPPED:
        startButton.setImageAlpha(64);
        break;
    case AdVpnService.VPN_STATUS_RUNNING:
        startButton.setImageAlpha(255);
        break;
    case AdVpnService.VPN_STATUS_RECONNECTING_NETWORK_ERROR:
        startButton.setImageAlpha(255);
        startButton.getDrawable().setTint(ContextCompat.getColor(context, R.color.stateError));
        break;
    }
}

From source file:com.battlelancer.seriesguide.util.Utils.java

/**
 * Tries to load the given TVDb show poster into the given {@link android.widget.ImageView}
 * without any resizing or cropping. In addition sets alpha on the view.
 *//*www. j a v  a2  s .com*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static void loadPosterBackground(Context context, ImageView imageView, String posterPath) {
    if (AndroidUtils.isJellyBeanOrHigher()) {
        imageView.setImageAlpha(30);
    } else {
        imageView.setAlpha(30);
    }

    loadPoster(context, imageView, posterPath);
}

From source file:org.chromium.chrome.browser.media.remote.ExpandedControllerActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (mVideoInfo.state == PlayerState.FINISHED)
        finish();//from  w w  w . j  av a2 s. c o m
    if (mMediaRouteController == null)
        return;

    // Lifetime of the media element is bound to that of the {@link MediaStateListener}
    // of the {@link MediaRouteController}.
    RecordCastAction.recordFullscreenControlsShown(mMediaRouteController.getMediaStateListener() != null);

    mMediaRouteController.prepareMediaRoute();

    ImageView iv = (ImageView) findViewById(R.id.cast_background_image);
    if (iv == null)
        return;
    Bitmap posterBitmap = mMediaRouteController.getPoster();
    if (posterBitmap != null)
        iv.setImageBitmap(posterBitmap);
    iv.setImageAlpha(POSTER_IMAGE_ALPHA);
}

From source file:com.weebly.opus1269.copyeverywhere.ui.shared.MenuTint.java

private void colorOverflowMenuItem(ImageView overflow) {
    if (overflow != null) {
        if (overflowDrawableId != null) {
            overflow.setImageResource(overflowDrawableId);
        }// w w  w. j a v a 2 s . c  o m
        if (menuItemIconColor != null) {
            overflow.setColorFilter(menuItemIconColor);
        }
        if (menuItemIconAlpha != null) {
            overflow.setImageAlpha(menuItemIconAlpha);
        }
    }
}

From source file:co.carlosjimenez.android.currencyalerts.app.MenuTint.java

private void colorOverflowMenuItem(ImageView overflow) {
    if (overflow != null) {
        if (overflowDrawableId != null) {
            overflow.setImageResource(overflowDrawableId);
        }/*from w w w . j  a  v  a  2s.  c om*/
        if (menuItemIconColor != null) {
            overflow.setColorFilter(menuItemIconColor);
        }
        if (menuItemIconAlpha != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                overflow.setImageAlpha(menuItemIconAlpha);
            } else {
                overflow.setAlpha(menuItemIconAlpha);
            }
        }
    }
}

From source file:com.weebly.opus1269.copyeverywhere.ui.main.MainActivity.java

/**
 * Initialize the NavigationView//from  www. ja v a  2  s  .c  o m
 *
 */
private void setupNavigationView() {
    final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView == null) {
        return;
    }
    navigationView.addOnLayoutChangeListener(this);

    // Handle click on header
    final View hView = navigationView.getHeaderView(0);
    hView.setOnClickListener(this);

    // set Devices menu state
    final Menu menu = navigationView.getMenu();
    final MenuItem deviceItem = menu.findItem(R.id.nav_devices);
    deviceItem.setEnabled(Prefs.isGcmRegistered());

    // set users avatar
    final String photoUri = Prefs.getPersonPhoto();
    final ImageView photo = (ImageView) hView.findViewById(R.id.personPhoto);
    if (!photoUri.isEmpty()) {
        photo.setImageAlpha(255);
        new LoadProfileImage(photo).execute(photoUri);
    } else {
        photo.setImageResource(R.drawable.ic_account_circle_24dp);
        photo.setImageAlpha(75);
    }

    // set users Google+ cover photo
    final String coverPhotoUri = Prefs.getPersonCoverPhoto();
    final LinearLayout coverPhoto = (LinearLayout) hView.findViewById(R.id.navHeader);
    if (!coverPhotoUri.isEmpty()) {
        new LoadCoverImage(coverPhoto).execute(coverPhotoUri);
    } else {
        final Drawable drawable = ContextCompat.getDrawable(this, R.drawable.side_nav_bar);
        coverPhoto.setBackground(drawable);
    }

    // set users account information
    final TextView name = (TextView) hView.findViewById(R.id.personName);
    final TextView email = (TextView) hView.findViewById(R.id.personEmail);
    name.setText(Prefs.getPersonName());
    email.setText(Prefs.getPersonEmail());
}