List of usage examples for android.view View setBackground
public void setBackground(Drawable background)
From source file:com.hellofyc.base.util.ViewUtils.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) static void blur(Context context, View view) { view.buildDrawingCache();/*from w w w. j a v a2 s . c o m*/ Bitmap srcBitmap = view.getDrawingCache(); float radius = 20f; Bitmap overlay = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(overlay); canvas.translate(-view.getLeft(), -view.getTop()); canvas.drawBitmap(srcBitmap, 0, 0, null); RenderScript script = RenderScript.create(context); Allocation allocation = Allocation.createFromBitmap(script, overlay); ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(script, allocation.getElement()); blur.setInput(allocation); blur.setRadius(radius); blur.forEach(allocation); allocation.copyTo(overlay); view.setBackground(new BitmapDrawable(context.getResources(), overlay)); script.destroy(); }
From source file:com.jvacx.appcoes.auth.fragments.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false); TypedArray bgs = getResources().obtainTypedArray(R.array.bgs); View view = rootView.findViewById(R.id.imgBackground); view.setBackground(bgs.getDrawable(getPageNumber())); return rootView; }
From source file:com.bt.viewpager.FragmentTabs.java
private TabSpec getTabSpec(String tag) { TabSpec tab = mTabHost.newTabSpec(tag); View v = View.inflate(this, R.layout.list_item_icon_text_v, null); tab.setIndicator(v);/*from www . j ava 2 s . c o m*/ v.setBackground(getResources().getDrawable(R.drawable.tabone)); return tab; }
From source file:de.Maxr1998.maxlock.thememanager.navigation.drawer.NavigationDrawerFragment.java
public void displayView(View view) { view.setBackground(getResources().getDrawable(R.color.background_selected)); ((TextView) view).setTextColor(getResources().getColor(R.color.accent)); Fragment fragment;/*from ww w. j av a 2s . co m*/ switch (view.getId()) { case R.id.installed_themes: fragment = new ThemeListFragment(); themeListFragment = (ThemeListFragment) fragment; break; case R.id.wiki: fragment = new WikiFragment(); themeListFragment = null; break; default: throw new IllegalArgumentException("View is null or not a drawer item!"); } getFragmentManager().beginTransaction().replace(R.id.frame_container, fragment).commit(); mDrawerLayout.closeDrawers(); }
From source file:com.gudong.appkit.ui.fragment.ColorChooseDialog.java
private void setBackgroundCompat(View view, Drawable d) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(d); } else {//from w w w . j a v a 2s. com //noinspection deprecation view.setBackgroundDrawable(d); } }
From source file:com.intirix.cloudpasswordmanager.pages.settings.SavePasswordOptionsViewHolder.java
private void setBackground(View view, int resource) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { view.setBackgroundDrawable(view.getResources().getDrawable(resource)); } else {// www. j a v a2 s .co m view.setBackground(view.getResources().getDrawable(resource)); } }
From source file:com.jameswolfeoliver.pigeon.Utilities.DrawableHelper.java
@SuppressWarnings("deprecation") public void applyToBackground(@NonNull View view) { if (mWrappedDrawable == null) { throw new NullPointerException(); }/*from w w w. ja va2 s .c o m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(mWrappedDrawable); } else { view.setBackgroundDrawable(mWrappedDrawable); } }
From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java
protected ExpandedViewHolder(View itemView) { super(itemView); final Context context = itemView.getContext(); itemView.setBackground(new LayerDrawable( new Drawable[] { ContextCompat.getDrawable(context, R.drawable.alarm_background_expanded), ThemeUtils.resolveDrawable(context, R.attr.selectableItemBackground) })); // Collapse handler itemView.setOnClickListener(new View.OnClickListener() { @Override/*from ww w . j a va2s .c om*/ public void onClick(View v) { getItemHolder().collapse(); notifyItemClicked(ItemAdapter.OnItemClickedListener.ACTION_ID_EXPANDED_VIEW); } }); if (arrow != null) { arrow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getItemHolder().collapse(); notifyItemClicked(ItemAdapter.OnItemClickedListener.ACTION_ID_EXPANDED_VIEW); } }); // Override arrow drawable if running Lollipop if (SystemUtils.isLMR1OrLater()) { arrow.setImageDrawable( ContextCompat.getDrawable(itemView.getContext(), R.drawable.ic_caret_up_animation)); } } itemView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); }
From source file:com.artioml.practice.LicenseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_license); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from ww w .ja va 2s .com*/ Button acceptButton = (Button) findViewById(R.id.acceptButton); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(IS_FIRST_TIME, true)) { getSupportActionBar().setDisplayShowHomeEnabled(false); getSupportActionBar().setHomeButtonEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(false); } if (getSharedPreferences(PERSISTENT_STORAGE, MODE_PRIVATE).getBoolean(IS_ACCEPTED, false)) { acceptButton.setVisibility(View.INVISIBLE); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } acceptButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getSharedPreferences(PERSISTENT_STORAGE, MODE_PRIVATE).edit().putBoolean(IS_ACCEPTED, true).apply(); finish(); } }); final View line = findViewById(R.id.lineView); line.post(new Runnable() { @Override public void run() { BitmapDrawable parallel = drawParallelogramLine(line.getWidth()); line.setBackground(parallel); } }); }
From source file:com.commonsware.android.dragdrop.MainActivity.java
private void applyDropHint(View v, int drawableId) { View parent = (View) v.getParent(); if (drawableId > -1) { parent.setBackgroundResource(drawableId); } else {/*from w w w .j av a2s.c o m*/ parent.setBackground(null); } }