Example usage for android.widget ImageView setBackgroundColor

List of usage examples for android.widget ImageView setBackgroundColor

Introduction

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

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:org.jitsi.android.gui.call.VideoCallActivity.java

/**
 * Updates on hold button to represent it's actual state.
 * Called from {@link #updateHoldStatus()}.
 *///from  w  w w. j av a2s  .  com
private void doUpdateHoldStatus() {
    final ImageView holdButton = (ImageView) findViewById(R.id.callHoldButton);

    if (isOnHold()) {
        holdButton.setBackgroundColor(0x50000000);
    } else {
        holdButton.setBackgroundColor(Color.TRANSPARENT);
    }
}

From source file:org.jitsi.android.gui.call.VideoCallActivity.java

private void doUpdateMuteStatus() {
    final ImageView microphoneButton = (ImageView) findViewById(R.id.callMicrophoneButton);

    if (isMuted()) {
        microphoneButton.setBackgroundColor(0x50000000);
        microphoneButton.setImageResource(R.drawable.callmicrophonemute);
    } else {/*from  ww  w.  j  a v  a  2 s . c o m*/
        microphoneButton.setBackgroundColor(Color.TRANSPARENT);
        microphoneButton.setImageResource(R.drawable.callmicrophone);
    }
}

From source file:net.maa123.tatuky.MainActivity.java

private void onFetchUserInfoSuccess(Account me, String domain) {
    // Add the header image and avatar from the account, into the navigation drawer header.
    headerResult.clear();/*from w  ww .jav  a 2  s . co  m*/

    ImageView background = headerResult.getHeaderBackgroundView();
    int backgroundWidth = background.getWidth();
    int backgroundHeight = background.getHeight();
    if (backgroundWidth == 0 || backgroundHeight == 0) {
        /* The header ImageView may not be layed out when the verify credentials call returns so
         * measure the dimensions and use those. */
        background.measure(View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY);
        backgroundWidth = background.getMeasuredWidth();
        backgroundHeight = background.getMeasuredHeight();
    }

    background.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark));

    Picasso.with(MainActivity.this).load(me.header).placeholder(R.drawable.account_header_default)
            .resize(backgroundWidth, backgroundHeight).centerCrop().into(background);

    headerResult.addProfiles(new ProfileDrawerItem().withName(me.getDisplayName())
            .withEmail(String.format("%s@%s", me.username, domain)).withIcon(me.avatar));

    // Show follow requests in the menu, if this is a locked account.
    if (me.locked) {
        PrimaryDrawerItem followRequestsItem = new PrimaryDrawerItem().withIdentifier(6)
                .withName(R.string.action_view_follow_requests).withSelectable(false)
                .withIcon(GoogleMaterial.Icon.gmd_person_add);
        drawer.addItemAtPosition(followRequestsItem, 3);
    }

    // Update the current login information.
    loggedInAccountId = me.id;
    loggedInAccountUsername = me.username;
    getPrivatePreferences().edit().putString("loggedInAccountId", loggedInAccountId)
            .putString("loggedInAccountUsername", loggedInAccountUsername)
            .putBoolean("loggedInAccountLocked", me.locked).apply();
}

From source file:com.radicaldynamic.groupinform.activities.LauncherActivity.java

private void displaySplash() {
    // Don't show the splash screen if this app appears to be registered
    if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
            .getString(InformOnlineState.DEVICE_ID, null) instanceof String) {
        return;//w w w  . j  a  v  a2s .  c  o  m
    }

    // Fetch the splash screen Drawable
    Drawable image = null;

    try {
        // Attempt to load the configured default splash screen
        // The following code only works in 1.6+
        // BitmapDrawable bitImage = new BitmapDrawable(getResources(), FileUtils.SPLASH_SCREEN_FILE_PATH);
        BitmapDrawable bitImage = new BitmapDrawable(
                FileUtilsExtended.EXTERNAL_FILES + File.separator + FileUtilsExtended.SPLASH_SCREEN_FILE);

        if (bitImage.getBitmap() != null && bitImage.getIntrinsicHeight() > 0
                && bitImage.getIntrinsicWidth() > 0) {
            image = bitImage;
        }
    } catch (Exception e) {
        // TODO: log exception for debugging?
    }

    // TODO: rework
    if (image == null) {
        // no splash provided...
        //            if (FileUtils.storageReady() && !((new File(FileUtils.DEFAULT_CONFIG_PATH)).exists())) {
        // Show the built-in splash image if the config directory 
        // does not exist. Otherwise, suppress the icon.
        image = getResources().getDrawable(R.drawable.gc_color);
        //            }

        if (image == null)
            return;
    }

    // Create ImageView to hold the Drawable...
    ImageView view = new ImageView(getApplicationContext());

    // Initialise it with Drawable and full-screen layout parameters
    view.setImageDrawable(image);

    int width = getWindowManager().getDefaultDisplay().getWidth();
    int height = getWindowManager().getDefaultDisplay().getHeight();

    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(width, height, 0);

    view.setLayoutParams(lp);
    view.setScaleType(ScaleType.CENTER);
    view.setBackgroundColor(Color.WHITE);

    // And wrap the image view in a frame layout so that the full-screen layout parameters are honoured
    FrameLayout layout = new FrameLayout(getApplicationContext());
    layout.addView(view);

    // Create the toast and set the view to be that of the FrameLayout
    mSplashToast = Toast.makeText(getApplicationContext(), "splash screen", Toast.LENGTH_LONG);
    mSplashToast.setView(layout);
    mSplashToast.setGravity(Gravity.CENTER, 0, 0);
    mSplashToast.show();
}

From source file:org.jitsi.android.gui.call.VideoCallActivity.java

/**
 * Updates speakerphone button status.//  www . j  a  v  a2s  .  c  o m
 */
private void updateSpeakerphoneStatus() {
    final ImageView speakerPhoneButton = (ImageView) findViewById(R.id.speakerphoneButton);

    if (JitsiApplication.getAudioManager().isSpeakerphoneOn()) {
        speakerPhoneButton.setBackgroundColor(0x50000000);
    } else {
        speakerPhoneButton.setBackgroundColor(Color.TRANSPARENT);
    }
}

From source file:gr.ioanpier.auth.users.memorypaintings.ImageDetails.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_details);
    String imagePath;/*from  w ww. j a  v a 2s  .  com*/
    imagePath = getIntent().getStringExtra("IMAGE_ID");
    ImageView imageView = ((ImageView) (findViewById(R.id.image)));

    if (imagePath == null) {
        ((findViewById(R.id.image))).setBackgroundColor(
                ContextCompat.getColor(this, getIntent().getIntExtra("COLOR_ID", R.color.black)));
    } else if (!imagePath.isEmpty()) {
        String drawableDesc = getIntent().getStringExtra("IMAGE_DESC");
        ((TextView) (findViewById(R.id.text))).setText(drawableDesc);

        imageView.setImageBitmap(null);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        //WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); // the results will be higher than using the activity context object or the getWindowManager() shortcut
        WindowManager wm = getWindowManager();
        wm.getDefaultDisplay().getMetrics(displayMetrics);
        int screenWidth = displayMetrics.widthPixels / 2;
        int screenHeight = displayMetrics.heightPixels / 2;

        imageView.setImageBitmap(Utility.decodeSampledBitmapFromPath(imagePath, screenWidth, screenHeight));
    } else {
        int color = getIntent().getIntExtra("COLOR_ID", R.color.black);
        imageView.setBackgroundColor(ContextCompat.getColor(this, color));

    }

    @SuppressWarnings("UnusedAssignment")
    PhotoViewAttacher mAttacher = new PhotoViewAttacher(imageView);
}

From source file:edu.cmu.cylab.starslinger.view.SlingerFragment.java

private void drawContactData(TextView textViewUserName, ListView listViewContactFields,
        ImageView imageViewPhoto) {
    // order: name, photo, phone, im, email, url, postal, title, org

    // make sure view is already inflated...
    if (listViewContactFields == null) {
        return;// w  w w. j a  va2s.  co m
    }

    mContactFields = new ArrayList<ContactField>();
    ContactFieldAdapter mAdapter;

    // draw name
    if (mContact.name != null && !TextUtils.isEmpty(mContact.name.toString())) {
        textViewUserName.setText(mContact.name.toString());
    } else {
        textViewUserName.setText("");
    }

    // draw photo
    imageViewPhoto.setBackgroundColor(Color.TRANSPARENT);
    try {
        if (mContact.photoBytes != null) {
            Bitmap bm = BitmapFactory.decodeByteArray(mContact.photoBytes, 0, mContact.photoBytes.length, null);
            imageViewPhoto.setImageBitmap(bm);
            imageViewPhoto.setAdjustViewBounds(true);

            mContactFields.add(new ContactField( //
                    R.drawable.ic_ks_photo, //
                    getString(R.string.label_Photo), //
                    ""));
        } else {
            imageViewPhoto.setImageDrawable(getResources().getDrawable(R.drawable.ic_silhouette));
        }
    } catch (OutOfMemoryError e) {
        imageViewPhoto.setImageDrawable(null);
    }

    // draw from phones
    if (mContact.phoneList != null)
        for (PhoneData m : mContact.phoneList) {

            mContactFields.add(new ContactField( //
                    R.drawable.ic_ks_phone, //
                    getPhoneTypeLabel(m.type, m.label), //
                    m.data));
        }

    // draw from contact methods
    if (mContact.contactmethodList != null) {

        // ims
        for (ContactMethod i : mContact.contactmethodList) {
            switch (i.kind) {
            case Contacts.KIND_IM:

                boolean isCustom = (i.kind == Contacts.KIND_IM) && mAccessor.isCustomIm(i.label);
                String data = i.data;
                String typeDisplay = "";
                int iconid = 0;
                boolean forceCheck = false;

                if (isCustom) {
                    iconid = R.drawable.ic_ks_key;
                    data = i.label;
                    typeDisplay = "";
                    forceCheck = true;
                } else {
                    iconid = R.drawable.ic_ks_im;
                    typeDisplay = mAccessor.getDesc(i.kind, i.type, i.label);
                }

                mContactFields.add(new ContactField( //
                        iconid, //
                        typeDisplay, //
                        delimitedString(data), forceCheck));
                break;
            default:
                break;
            }
        }

        // emails
        for (ContactMethod e : mContact.contactmethodList) {
            switch (e.kind) {
            case Contacts.KIND_EMAIL:
                String data = e.data;
                String typeDisplay = "";
                int iconid = 0;
                boolean forceCheck = false;

                iconid = R.drawable.ic_ks_email;
                typeDisplay = getEmailTypeLabel(e.type, e.label);

                mContactFields.add(new ContactField( //
                        iconid, //
                        typeDisplay, //
                        delimitedString(data), forceCheck));
                break;
            default:
                break;
            }
        }

        // urls
        for (ContactMethod u : mContact.contactmethodList) {
            switch (u.kind) {
            case Contacts.KIND_URL:

                String data = u.data;
                String typeDisplay = "";
                int iconid = 0;
                boolean forceCheck = false;

                iconid = R.drawable.ic_ks_url;

                mContactFields.add(new ContactField( //
                        iconid, //
                        typeDisplay, //
                        delimitedString(data), forceCheck));
                break;
            default:
                break;
            }
        }
    }

    // draw from addresses
    if (mContact.addressList != null)
        for (Address m : mContact.addressList) {

            mContactFields.add(new ContactField( //
                    R.drawable.ic_ks_postal, //
                    getStructuredPostalTypeLabel(m.getType(), m.getLabel()), //
                    delimitedString(m.toString())));
        }

    mAdapter = new ContactFieldAdapter(getActivity(), mContactFields);
    listViewContactFields.setAdapter(mAdapter);

    // restore list position
    listViewContactFields.setSelectionFromTop(mListVisiblePos, mListTopOffset);
}

From source file:com.fa.mastodon.activity.MainActivity.java

private void onFetchUserInfoSuccess(Account me, String domain) {
    // Add the header image and avatar from the account, into the navigation drawer header.
    headerResult.clear();//from w w  w.j  a v a  2  s  .  c  o m

    ImageView background = headerResult.getHeaderBackgroundView();
    int backgroundWidth = background.getWidth();
    int backgroundHeight = background.getHeight();
    if (backgroundWidth == 0 || backgroundHeight == 0) {
        /* The header ImageView may not be layed out when the verify credentials call returns so
         * measure the dimensions and use those. */
        background.measure(View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY);
        backgroundWidth = background.getMeasuredWidth();
        backgroundHeight = background.getMeasuredHeight();
    }

    background.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark));

    if (backgroundWidth == 0 || backgroundHeight == 0) {
    } else {
        Picasso.with(MainActivity.this).load(me.header).placeholder(R.drawable.account_header_default)
                .resize(backgroundWidth, backgroundHeight).centerCrop().into(background);
    }

    headerResult.addProfiles(new ProfileDrawerItem().withName(me.getDisplayName())
            .withEmail(String.format("%s@%s", me.username, domain)).withIcon(me.avatar));

    // Show follow requests in the menu, if this is a locked account.
    if (me.locked) {
        PrimaryDrawerItem followRequestsItem = new PrimaryDrawerItem().withIdentifier(6)
                .withName(R.string.action_view_follow_requests).withSelectable(false)
                .withIcon(GoogleMaterial.Icon.gmd_person_add);
        drawer.addItemAtPosition(followRequestsItem, 3);
    }

    // Update the current login information.
    loggedInAccountId = me.id;
    loggedInAccountUsername = me.username;
    getPrivatePreferences().edit().putString("loggedInAccountId", loggedInAccountId)
            .putString("loggedInAccountUsername", loggedInAccountUsername)
            .putBoolean("loggedInAccountLocked", me.locked).apply();
}

From source file:com.futurice.hereandnow.view.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//from w  w w  . j  a  va2  s .co  m
        TextView tabTitleView = null;
        ImageView tabImageView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            //tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
            tabImageView = (ImageView) tabView.findViewById(R.id.tab_image_view);
        } else {
            tabView = createDefaultTabView(getContext());

        }

        if (tabImageView == null && ImageView.class.isInstance(tabView)) {
            tabImageView = (ImageView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT,
                    1.0f);
            tabView.setLayoutParams(lp);
        }

        //tabTitleView.setText(adapter.getPageTitle(i));
        tabImageView.setBackgroundColor(ViewUtils.getColor(getContext(), i));
        tabImageView.setImageResource(Constants.TAB_ICONS[i]);
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:com.android.tv.settings.dialog.DialogFragment.java

private void setContentView(View content) {
    TextView titleView = (TextView) content.findViewById(R.id.title);
    TextView breadcrumbView = (TextView) content.findViewById(R.id.breadcrumb);
    TextView descriptionView = (TextView) content.findViewById(R.id.description);
    titleView.setText(mTitle);//from   w  w  w  .j  av a2s.c o m
    breadcrumbView.setText(mBreadcrumb);
    descriptionView.setText(mDescription);
    final ImageView iconImageView = (ImageView) content.findViewById(R.id.icon);
    if (mIconBackgroundColor != Color.TRANSPARENT) {
        iconImageView.setBackgroundColor(mIconBackgroundColor);
    }

    if (AccessibilityHelper.forceFocusableViews(getActivity())) {
        titleView.setFocusable(true);
        titleView.setFocusableInTouchMode(true);
        descriptionView.setFocusable(true);
        descriptionView.setFocusableInTouchMode(true);
        breadcrumbView.setFocusable(true);
        breadcrumbView.setFocusableInTouchMode(true);
    }

    if (mIconResourceId != 0) {
        iconImageView.setImageResource(mIconResourceId);
        updateViewSize(iconImageView);
    } else {
        if (mIconBitmap != null) {
            iconImageView.setImageBitmap(mIconBitmap);
            updateViewSize(iconImageView);
        } else {
            if (mIconUri != null) {
                iconImageView.setVisibility(View.INVISIBLE);

                DrawableDownloader bitmapDownloader = DrawableDownloader.getInstance(content.getContext());
                mBitmapCallBack = new BitmapCallback() {
                    @Override
                    public void onBitmapRetrieved(Drawable bitmap) {
                        if (bitmap != null) {
                            mIconBitmap = (bitmap instanceof BitmapDrawable)
                                    ? ((BitmapDrawable) bitmap).getBitmap()
                                    : null;
                            iconImageView.setVisibility(View.VISIBLE);
                            iconImageView.setImageDrawable(bitmap);
                            updateViewSize(iconImageView);
                        }
                    }
                };

                bitmapDownloader.getBitmap(new BitmapWorkerOptions.Builder(content.getContext())
                        .resource(mIconUri).width(iconImageView.getLayoutParams().width).build(),
                        mBitmapCallBack);
            } else {
                iconImageView.setVisibility(View.GONE);
            }
        }
    }

    content.setTag(R.id.title, titleView);
    content.setTag(R.id.breadcrumb, breadcrumbView);
    content.setTag(R.id.description, descriptionView);
    content.setTag(R.id.icon, iconImageView);
}