View getBackground - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for View getBackground method.

This code example shows how to use the following methods:getBackground, getHeight, getPaddingBottom, getPaddingTop, getTop
This code example shows how to use the following methods:getBackground, invalidate
		setKey(key);
	} 
 
	public static void applyBackground(final View view, final int color) {
		if (view == null) return;
		final Drawable bg = view.getBackground();
		if (bg == null) return;
		bg.mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
		view.invalidate();
	} 
 
	public static int getThemeColor(final Context context) {
		final Resources res = context.getResources();
		final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
		final boolean dark_theme = prefs.getBoolean(PREFERENCE_KEY_DARK_THEME, false);
		final int def = res.getColor(dark_theme ? R.color.holo_blue_dark : R.color.holo_blue_light);
		final String key = dark_theme ? PREFERENCE_KEY_DARK_THEME_COLOR : PREFERENCE_KEY_LIGHT_THEME_COLOR;
		return prefs.getInt(key, def);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getBackground, setBackgroundDrawable
        } 
 
        // runs on the UI thread 
        @Override protected void onPostExecute(String msg) {
            if (0 >= --mInFlight) {
                ((AnimationDrawable) dots.getBackground()).stop();
                dots.setBackgroundDrawable(bg);
            } 
 
            message.setText(msg);
        } 
 
        // runs on its own thread 
        @Override protected String doInBackground(String... args) {
            return ((1 != args.length) || (null == args[0]))
                ? null 
                : game.initialize(args[0], this);
        } 
 
        @Override protected void onProgressUpdate(Integer... vals) {
7
CodeRank
This code example shows how to use the following methods:getBackground, setBackgroundResource
			View content = contentParent.getChildAt(0);
			contentParent.removeView(content);
			contentParent.addView(this, 0, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
			setContent(content);
			// save people from having transparent backgrounds 
			if (content.getBackground() == null)
				content.setBackgroundResource(background);
			break; 
		} 
	} 
 
	/** 
	 * Set the above view content from a layout resource. The resource will be inflated, adding all top-level views 
	 * to the above view. 
	 * 
	 * @param res the new content 
	 */ 
	public void setContent(int res) {
		setContent(LayoutInflater.from(getContext()).inflate(res, null));
	} 

6
CodeRank
This code example shows how to use the following methods:getBackground, getHeight, getPaddingBottom, getPaddingTop, getTop
7
CodeRank
This code example shows how to use the following methods:getBackground, setImageResource
This code example shows how to use the following methods:getBackground, layout
         * @param b the parent's bottom border 
         * @param alignment which side to align the widget to 
         */ 
        void layout(int l, int t, int r, int b, int alignment) {
            this.alignment = alignment;
            final Drawable tabBackground = tab.getBackground();
            final int handleWidth = tabBackground.getIntrinsicWidth();
            final int handleHeight = tabBackground.getIntrinsicHeight();
            final Drawable targetDrawable = target.getDrawable();
            final int targetWidth = targetDrawable.getIntrinsicWidth();
            final int targetHeight = targetDrawable.getIntrinsicHeight();
            final int parentWidth = r - l;
            final int parentHeight = b - t;
 
            final int leftTarget = (int) (THRESHOLD * parentWidth) - targetWidth + handleWidth / 2;
            final int rightTarget = (int) ((1.0f - THRESHOLD) * parentWidth) - handleWidth / 2;
            final int left = (parentWidth - handleWidth) / 2;
            final int right = left + handleWidth;
 
            if (alignment == ALIGN_LEFT || alignment == ALIGN_RIGHT) {

6
CodeRank
This code example shows how to use the following methods:getBackground
   * 
   * @return the resource ID of this view's background 
   * @deprecated Use FEST assertions instead. 
   */ 
  public int getBackgroundResourceId() { 
    Drawable drawable = realView.getBackground();
    return drawable instanceof BitmapDrawable
        ? shadowOf(((BitmapDrawable) drawable).getBitmap()).getCreatedFromResId()
        : -1; 
  } 
 
  /** 
   * Non-Android accessor. 
   * 
   * @return the color of this view's background, or 0 if it's not a solid color 
   * @deprecated Use FEST assertions instead. 
   */ 
  public int getBackgroundColor() { 
    Drawable drawable = realView.getBackground();
    return drawable instanceof ColorDrawable ? ((ColorDrawable) drawable).getColor() : 0;
6
CodeRank
This code example shows how to use the following methods:getBackground, setBackgroundDrawable
        } 
 
        // runs on the UI thread 
        @Override protected void onPostExecute(String msg) {
            if (0 >= --mInFlight) {
                ((AnimationDrawable) dots.getBackground()).stop();
                dots.setBackgroundDrawable(bg);
            } 
 
            message.setText(msg);
        } 
 
        // runs on its own thread 
        @Override protected String doInBackground(String... args) {
            return ((1 != args.length) || (null == args[0]))
                ? null 
                : game.initialize(args[0]);
        } 
    } 
 
6
CodeRank
This code example shows how to use the following methods:getBackground, getLayoutParams, setBackgroundDrawable
    private ViewGroup wrapChild(View aChild) {
        int index = indexOfChild(aChild);
        FrameLayout f = new FrameLayout(getContext());
        removeView(aChild);
 
        f.setBackgroundDrawable(aChild.getBackground());
        aChild.setBackgroundDrawable(null);
 
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        addView(f, index, params);
        f.addView(aChild, 0, aChild.getLayoutParams());
 
        return f;
    } 
 
    public void setSwipeable(boolean aIsSwipeable) {
        mSwipeable = aIsSwipeable;
    } 
 
    public void setOpen(boolean isOpen) {
6
CodeRank

Related View getBackground Questions & Answers:

Other View getBackground Examples

23:	
24:			// layout background transparent
25:			llStats.getBackground().setAlpha(150);
26:			llStats.setVisibility(View.VISIBLE);
27:

Read More

getBackground Method Overview
Gets the background drawable
See Code Examples for other Android View Methods: