getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title_bar); View title = getWindow().findViewById(R.id.mainlayout); title.setBackgroundDrawable(gd);
/** * Apply the specified drawable to the system navigation bar. * * @param drawable The drawable to use as the background, or null to remove it. */ @SuppressWarnings("deprecation") public void setNavigationBarTintDrawable(Drawable drawable) { if (mNavBarAvailable) { mNavBarTintView.setBackgroundDrawable(drawable); } }
/** * Apply the specified drawable to the system status bar. * * @param drawable The drawable to use as the background, or null to remove it. */ @SuppressWarnings("deprecation") public void setStatusBarTintDrawable(Drawable drawable) { if (mStatusBarAvailable) { mStatusBarTintView.setBackgroundDrawable(drawable); } }
/** * Apply the specified drawable to the system status bar. * * @param drawable The drawable to use as the background, or null to remove it. */ @SuppressWarnings("deprecation") public void setStatusBarTintDrawable(Drawable drawable) { if (mStatusBarAvailable) { mStatusBarTintView.setBackgroundDrawable(drawable); } }
/** * Apply the specified drawable to the system navigation bar. * * @param drawable The drawable to use as the background, or null to remove it. */ @SuppressWarnings("deprecation") public void setNavigationBarTintDrawable(Drawable drawable) { if (mNavBarAvailable) { mNavBarTintView.setBackgroundDrawable(drawable); } }
/** * Apply the specified drawable to the system status bar. * * @param drawable The drawable to use as the background, or null to remove it. */ @SuppressWarnings("deprecation") public void setStatusBarTintDrawable(Drawable drawable) { if (mStatusBarAvailable) { mStatusBarTintView.setBackgroundDrawable(drawable); } }
/** * Apply the specified drawable to the system navigation bar. * * @param drawable The drawable to use as the background, or null to remove it. */ @SuppressWarnings("deprecation") public void setNavigationBarTintDrawable(Drawable drawable) { if (mNavBarAvailable) { mNavBarTintView.setBackgroundDrawable(drawable); } }
public static void setBackground(View v, Drawable drawable){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) v.setBackground(drawable); else v.setBackgroundDrawable(drawable); }
@SuppressWarnings("deprecation") private static void setBackgroundCompat(View view, Drawable drawable) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { view.setBackgroundDrawable(drawable); } else { view.setBackground(drawable); } }
private void setBackground(Drawable backgroundDrawable) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { mView.setBackgroundDrawable(backgroundDrawable); } else { mView.setBackground(backgroundDrawable); } }
public static void setBackground(View view, Drawable background) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(background); } else { view.setBackgroundDrawable(background); } }
public static void setBackground(View v, Drawable drawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { v.setBackground(drawable); } else { v.setBackgroundDrawable(drawable); } }
public static void setBackground(View view, Drawable background) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) view.setBackground(background); else view.setBackgroundDrawable(background); }
static void setBackground(@NonNull View view, Drawable drawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) view.setBackground(drawable); else view.setBackgroundDrawable(drawable); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void setBackground(View view, Drawable drawable) { if (Build.VERSION.SDK_INT < 16) { //noinspection deprecation view.setBackgroundDrawable(drawable); } else { view.setBackground(drawable); } }
View layout = findViewById(R.id.mainlayout); GradientDrawable gd = new GradientDrawable( GradientDrawable.Orientation.TOP_BOTTOM, new int[] {0xFF616261,0xFF131313}); gd.setCornerRadius(0f); layout.setBackgroundDrawable(gd);
@Override public void setBackgroundDrawable(Drawable background) { super.setBackgroundDrawable(background); if (mBackgroundHelper != null) { mBackgroundHelper.setBackgroundDrawableExternal(background); } }
@Override public void setBackgroundDrawable(Drawable drawable) { Drawable background = getBackground(); if(background instanceof RippleDrawable && !(drawable instanceof RippleDrawable)) ((RippleDrawable) background).setBackgroundDrawable(drawable); else super.setBackgroundDrawable(drawable); }
@Override public void setBackgroundDrawable(Drawable drawable) { Drawable background = getBackground(); if(background instanceof RippleDrawable && !(drawable instanceof RippleDrawable)) ((RippleDrawable) background).setBackgroundDrawable(drawable); else super.setBackgroundDrawable(drawable); }
@Test public void shouldRecordBackgroundDrawable() { Drawable drawable = new BitmapDrawable(BitmapFactory.decodeFile("some/fake/file")); view.setBackgroundDrawable(drawable); assertThat(view.getBackground()).isSameAs(drawable); assertThat(ShadowView.visualize(view)).isEqualTo("background:\nBitmap for file:some/fake/file"); }