Example usage for android.view View setBackgroundDrawable

List of usage examples for android.view View setBackgroundDrawable

Introduction

In this page you can find the example usage for android.view View setBackgroundDrawable.

Prototype

@Deprecated
public void setBackgroundDrawable(Drawable background) 

Source Link

Usage

From source file:saphion.pageindicators.FixedTabsView.java

/**
 * Creates and returns a new Separator View
 * //from   w  w  w .  ja va 2  s .c  om
 * @return
 */
@SuppressWarnings("deprecation")
private View getSeparator() {
    View v = new View(mContext);

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, LayoutParams.MATCH_PARENT);
    params.setMargins(0, mDividerMarginTop, 0, mDividerMarginBottom);
    v.setLayoutParams(params);

    if (mDividerDrawable != null)
        v.setBackgroundDrawable(mDividerDrawable);
    else
        v.setBackgroundColor(mDividerColor);

    return v;
}

From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.AmharicKeyboardView.java

private void handleChild(View child, int columnCount, LinearLayout keyContainer, int keyHeight) {
    child.setBackgroundDrawable(ContextCompat.getDrawable(getContext(), R.drawable.amharic_key_bg));
    child.setOnTouchListener(new OnTouchListener() {
        @Override// www . j  a  v  a2s .co m
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                if (shouldVibrate) {
                    Vibrator vb = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
                    if (vb != null) {
                        vb.vibrate(20);
                    }
                }
                mPressedKeyView = v;
                mHandler.removeCallbacks(mKeyPressRunnable);
                mHandler.postAtTime(mKeyPressRunnable, mPressedKeyView,
                        SystemClock.uptimeMillis() + INITIAL_INTERVAL);
                break;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_OUTSIDE:
                mHandler.removeCallbacksAndMessages(mPressedKeyView);
                mPressedKeyView = null;
                mNormalInterval = 100;
                break;
            }
            return false;
        }
    });
    child.setOnClickListener(mKeyClickListener);
    int margin = getCustomSize(1.5f);
    int tempKeyHeight = keyHeight - (margin * 2);
    LayoutParams params = new LayoutParams(0, tempKeyHeight, columnCount);
    params.setMargins(margin, margin, margin, margin);
    keyContainer.addView(child, params);
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

@Override
protected void onResume() {

    mTabHost.getTabWidget().getChildAt(4)
            .setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_tabs));

    View setup_hbar = mTabHost.getTabWidget().getChildAt(4).findViewWithTag("hbar");

    setup_hbar.setBackgroundDrawable(null);
    setup_hbar.setBackgroundColor(resources.getColor(R.color.graylight));

    btSetup.setBackgroundDrawable(null);

    btSetup.bringToFront();/* ww w  . j a  v  a  2 s . c o m*/
    super.onResume();
    btSetup.bringToFront();

    //--------- Vanish zoom view of issue ------------
    if (Fragment_Issue_Details.dialogZoomIm != null)
        if (Fragment_Issue_Details.dialogZoomIm.isShowing())
            Fragment_Issue_Details.dialogZoomIm.dismiss();
}

From source file:com.yacorso.nowaste.views.adapters.FridgeFoodAdapter.java

private void setOpenIcon(View v, Food food) {
    Drawable icon;/*from   w  ww. j a  v a  2  s. co m*/
    if (food.getFoodFridge().isOpen()) {
        icon = ContextCompat.getDrawable(mContext, R.drawable.food_started);
    } else {
        icon = ContextCompat.getDrawable(mContext, R.drawable.food_not_started);
    }

    if (android.os.Build.VERSION.SDK_INT >= 16) {
        v.setBackground(icon);
    } else {
        v.setBackgroundDrawable(icon);
    }
}

From source file:online.privacy.SetupActivity.java

@SuppressWarnings("deprecation")
private void setErrorState(View view) {
    ColorStateList stateList = ContextCompat.getColorStateList(activitySetup, R.color.input_text_error);
    Drawable wrappedDrawable = DrawableCompat.wrap(view.getBackground());
    DrawableCompat.setTintList(wrappedDrawable, stateList);
    view.setBackgroundDrawable(wrappedDrawable);
}

From source file:com.emilsjolander.components.stickylistheaders.StickyListHeadersCursorAdapter.java

private View attachDividerToListItem(View listItem) {
    WrapperView wrapper = null;//from   w ww  . ja  v  a 2s.  com
    if (wrapperCache.size() > 0) {
        wrapper = wrapperCache.remove(0);
    }
    if (wrapper == null) {
        wrapper = new WrapperView(context);
    }
    View divider = null;
    if (dividerCache.size() > 0) {
        divider = dividerCache.remove(0);
    }
    if (divider == null) {
        divider = new View(context);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(MATCH_PARENT, dividerHeight);
        divider.setLayoutParams(params);
    }
    divider.setBackgroundDrawable(this.divider);
    return wrapper.wrapViews(listItem, divider, null);
}

From source file:online.privacy.SetupActivity.java

@SuppressWarnings("deprecation")
private void clearErrorState(View view) {
    ColorStateList stateList = ContextCompat.getColorStateList(activitySetup, R.color.input_text_normal);
    Drawable wrappedDrawable = DrawableCompat.wrap(view.getBackground());
    DrawableCompat.setTintList(wrappedDrawable, stateList);
    view.setBackgroundDrawable(wrappedDrawable);
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

private LinearLayout ActivateColorize(LinearLayout ll, String text, Drawable dr) {

    // text//from   ww  w.ja  va2s  . c om
    TextView v = (TextView) ll.findViewWithTag("tv");
    v.setText(text);
    v.setTextSize(10);
    v.setTextColor(Color.BLACK); //v.setTextColor(Color.WHITE);
    v.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);

    //dr.setColorFilter(0xFF888888, android.graphics.PorterDuff.Mode.MULTIPLY);
    dr.setColorFilter(resources.getColor(R.color.orange), android.graphics.PorterDuff.Mode.SRC_ATOP);

    v.setCompoundDrawablesWithIntrinsicBounds(null, dr, null, null);
    v.setPadding(0, 5, 0, 2);

    v.setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_tabs_focused));

    // hbar
    View hbar = ll.findViewWithTag("hbar");
    //hbar.setBackgroundColor(resources.getColor(R.color.orange));
    hbar.setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_orange));

    return ll;
}

From source file:io.imoji.sdk.editor.fragment.TagImojiFragment.java

@Override
public void onViewCreated(View v, @Nullable Bundle savedInstanceState) {
    mImojiIv = (ImageView) v.findViewById(R.id.iv_imoji);
    mTagEditor = v.findViewById(R.id.tag_editor);
    mTagEditor.setBackgroundDrawable(createTagDrawable());
    mTagGrid = (GridLayout) v.findViewById(R.id.gl_tagbox);
    mTaggerEt = (EditText) v.findViewById(R.id.et_tag);
    mTaggerEt.setOnEditorActionListener(mKeyActionListener);
    mUploadButton = (ImageButton) v.findViewById(R.id.ib_upload);
    mUploadButton.setOnClickListener(mOnDoneClickListener);
    mProgress = (ProgressBar) v.findViewById(R.id.imoji_progress);

    mToolbar = (Toolbar) v.findViewById(R.id.imoji_toolbar);
    mToolbar.setNavigationIcon(R.drawable.create_back);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override/*from  ww w  .j  a  v  a  2  s. co  m*/
        public void onClick(View v) {
            if (isResumed()) {
                getFragmentManager().popBackStack();
                mInputMethodManager.hideSoftInputFromWindow(mTaggerEt.getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);

            }
        }
    });

    mClearInputBt = (ImageButton) v.findViewById(R.id.ib_cancel);
    mClearInputBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mTaggerEt != null) {
                mTaggerEt.getText().clear();
            }
        }
    });

    View toolbarScrim = v.findViewById(R.id.imoji_toolbar_scrim);
    if (Build.VERSION.SDK_INT >= 16) {
        toolbarScrim.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0x66000000, 8, Gravity.TOP));
    } else {
        toolbarScrim
                .setBackgroundDrawable(ScrimUtil.makeCubicGradientScrimDrawable(0x66000000, 8, Gravity.TOP));
    }

    if (savedInstanceState != null) {
        List<String> tags = savedInstanceState.getStringArrayList(TAGS_BUNDLE_ARG_KEY);
        for (String tag : tags) {
            addTagChip(tag);
        }

        mProgress.setVisibility(
                savedInstanceState.getBoolean(IS_PROCESSING_BUNDLE_ARG_KEY) ? View.VISIBLE : View.GONE);
    }

}

From source file:aierjun.com.aierjunlibrary.widget.tablayout.PagerSlidingTabStrip.java

private void checkBackground(int position) {
    for (int i = 0; i < tabCount; i++) {
        View vs = tabsContainer.getChildAt(i);
        vs.setBackgroundDrawable(getResources().getDrawable(android.R.color.transparent));
        if (vs instanceof TextView) {
            TextView tab = (TextView) vs;
            tab.setTextColor(getResources().getColor(android.R.color.black));
        }/*from  w  w  w . j  a  v a 2 s  . com*/
    }
    View vs = tabsContainer.getChildAt(position);
    vs.setBackgroundDrawable(tabBackgroundDrawable);
    if (vs instanceof TextView) {
        TextView tab = (TextView) vs;
        tab.setTextColor(tabchecktextcolor);
    }
}