Java Code Examples for android.support.v7.app.ActionBar#setBackgroundDrawable()
The following examples show how to use
android.support.v7.app.ActionBar#setBackgroundDrawable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityHeaderController.java From MiPushFramework with GNU General Public License v3.0 | 6 votes |
public EntityHeaderController styleActionBar(AppCompatActivity activity) { if (activity == null) { Log.w(TAG, "No activity, cannot style actionbar."); return this; } final ActionBar actionBar = activity.getSupportActionBar(); if (actionBar == null) { Log.w(TAG, "No actionbar, cannot style actionbar."); return this; } actionBar.setBackgroundDrawable( new ColorDrawable(Utils.getColorAttr(activity, R.attr.colorSettings))); actionBar.setElevation(0); //if (mRecyclerView != null && mLifecycle != null) { // ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView); //} return this; }
Example 2
Source File: SlidingTabLayout.java From android-sliderview with MIT License | 5 votes |
public void attachToActionBar(ActionBar bar) { this.bar = bar; if (bar != null) { bar.setElevation(0); barBackground = new ColorDrawable(((ColorDrawable) getBackground()).getColor()); bar.setBackgroundDrawable(barBackground); } }
Example 3
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 5 votes |
/** * Sets Actionbar background color * @param obj */ private void handleSetBackgroundColor(String color){ ActionBar actionBar = getActionBar(); if (actionBar == null){ return; } actionBar.setBackgroundDrawable(new ColorDrawable(TiConvert.toColor(color))); }
Example 4
Source File: ProductDetailsActivity.java From ShoppingCartDemo with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_product_details); ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33000000"))); //google的actionbar是分为上下两栏显示的,上面的代码只能设置顶部actionbar的背景色, //为了让下面的背景色一致,还需要添加一行代码: actionBar.setSplitBackgroundDrawable(new ColorDrawable(Color.parseColor("#33000000"))); initViews(); initDatas(); addListeners(); }
Example 5
Source File: MainActivity.java From freeiot-android with MIT License | 5 votes |
public void restoreActionBar() { ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(getResources().getDrawable(R.color.main_red_color)); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(mTitle); }
Example 6
Source File: TakeoffActivity.java From OnboardMe with GNU General Public License v2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_takeoff); ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(0xFFFFA500)); }
Example 7
Source File: SourceViewerActivity.java From android-classyshark with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_source_viewer); getWindow().getDecorView().setBackgroundColor(Color.BLACK); ActionBar bar = getSupportActionBar(); bar.setBackgroundDrawable(new ColorDrawable(0xff606060)); String result = ""; try { String name = getIntent().getStringExtra(ClassesListActivity.SELECTED_CLASS_NAME); String barName = name.substring(name.lastIndexOf(".") + 1); bar.setTitle((Html.fromHtml("<font color=\"#FFFF80\">" + barName + "</font>"))); result = getIntent().getStringExtra(ClassesListActivity.SELECTED_CLASS_DUMP); } catch (Exception e) { e.printStackTrace(); } sourceCodeText = result; sourceCodeText = HtmlEscapers.htmlEscaper().escape(sourceCodeText); WebView webView = (WebView) findViewById(R.id.source_view); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setDefaultTextEncodingName("utf-8"); webView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { } }); webView.loadDataWithBaseURL("file:///android_asset/", "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><script src=\"run_prettify.js?skin=sons-of-obsidian\"></script></head><body bgcolor=\"#000000\"><pre class=\"prettyprint \">" + sourceCodeText + "</pre></body></html>", "text/html", "UTF-8", null); }
Example 8
Source File: GalleryActivity.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
private void configToolbar() { toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_toolbar_shade)); actionBar.setTitle(title); actionBar.setSubtitle(clickedImage + 1 + "/" + attachments.size()); } }
Example 9
Source File: BaseFragmentActivity.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Configure ActionBar ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setElevation(0); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowCustomEnabled(false); if (STYLE.getToolBarColor() != 0) { actionBar.setBackgroundDrawable(new ColorDrawable(STYLE.getToolBarColor())); } } // Setting basic content FrameLayout rootLayout = new FrameLayout(this); rootLayout.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); rootLayout.setBackgroundColor(STYLE.getMainBackgroundColor()); rootLayout.setId(R.id.content_frame); setContentView(rootLayout); // Setting Background Color getWindow().setBackgroundDrawable(new ColorDrawable(STYLE.getMainBackgroundColor())); }
Example 10
Source File: ConversationActivity.java From Atomic with GNU General Public License v3.0 | 5 votes |
private void setupColors() { if( settings.tintActionbar() ) { // the ActionBar can be tinted. This is really cool. // Get the ActionBar ActionBar ab = getSupportActionBar(); // Make its background drawable a ColorDrawable ab.setBackgroundDrawable(new ColorDrawable(_scheme.getBackground())); _mainToolbar.setBackgroundColor(_scheme.getBackground()); // Create a SpannableString from the current server. SpannableString st = new SpannableString(server.getTitle()); // Make its forground color (through a ForgroundColorSpan) to be the // foreground of the scheme. // This is because you can't guarantee that the ActionBar text color and // actionbar color aren't going to be the same. st.setSpan(new ForegroundColorSpan(_scheme.getForeground()), 0, st.length(), SpannableString.SPAN_INCLUSIVE_INCLUSIVE); // Now, set our spannable to be the ActionBar title. _mainToolbar.setTitle(st); } else { (getSupportActionBar()).setTitle(server.getTitle()); } EditText input = (EditText)findViewById(R.id.input); LinearLayout lll = (LinearLayout)(input.getParent()); lll.setBackgroundColor(_scheme.getBackground()); input.setTextColor(_scheme.getForeground()); }
Example 11
Source File: MainActivity.java From Minitask with Apache License 2.0 | 5 votes |
private void applyNewColor (String actionBarColor, String tabStripColor, String indicatorColor) { ActionBar actionBar = getSupportActionBar(); Window window = this.getWindow(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(actionBarColor))); window.setStatusBarColor(Color.parseColor(indicatorColor)); tabStrip.setBackground(new ColorDrawable((Color.parseColor(tabStripColor)))); tabStrip.setIndicatorColor(Color.parseColor(indicatorColor)); actionButton.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(actionBarColor))); }
Example 12
Source File: ThemeUtils.java From SuperNote with GNU General Public License v3.0 | 4 votes |
public static void resetToolbarColor(Context context){ int color=getColorPrimary(context); ActionBar actionBar=((AppCompatActivity)context).getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(color)); }
Example 13
Source File: ThemeUtils.java From SuperNote with GNU General Public License v3.0 | 4 votes |
public static void setToolbarColor(ActionBar actionBar, int color){ actionBar.setBackgroundDrawable(new ColorDrawable(color)); }
Example 14
Source File: GroupInfoFragment.java From actor-platform with GNU Affero General Public License v3.0 | 4 votes |
@Override public void onConfigureActionBar(ActionBar actionBar) { super.onConfigureActionBar(actionBar); actionBar.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); }
Example 15
Source File: RecordingActivity.java From Android-Audio-Recorder with Apache License 2.0 | 4 votes |
private void setupActionBar() { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setBackgroundDrawable(new ColorDrawable(MainApplication.getActionbarColor(this))); } }
Example 16
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Defaults.setupInitialValues(getApplicationContext(), getIntent()); if (!Defaults.ACTIVITY_THEME.isEmpty()) { setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME)); } setupIds(); setContentView(main_layout_id); isMultipleSelection = (1 != Defaults.MAX_IMAGE_SELECTION); isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE; if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (!Defaults.STATUS_BAR_COLOR.isEmpty()) { window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR)); } window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR)); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { if (!Defaults.BAR_COLOR.isEmpty()) { actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR)); } actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(Defaults.TITLE); } else { Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG); } mRecyclerView = new RecyclerView(TiApplication.getInstance()); mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView.setLayoutManager(new GridLayoutManager(ImagePickerActivity.this, Defaults.GRID_SIZE)); FrameLayout frame_container = (FrameLayout) findViewById(container); frame_container.addView(mRecyclerView); frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR)); adapterSet = new PhotoAdapter(adapter); mRecyclerView.setAdapter(adapterSet); if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) { mRecyclerView.addItemDecoration(new DividerDecoration()); } setupGlideOptions(); // set glide-options to apply on image // Get gallery photos in a new UI thread like AsyncTask to update UI changes properly new FetchImages().execute(); }
Example 17
Source File: ProfileFragment.java From actor-platform with GNU Affero General Public License v3.0 | 4 votes |
@Override public void onConfigureActionBar(ActionBar actionBar) { super.onConfigureActionBar(actionBar); actionBar.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); }
Example 18
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); imagesAdapter = intent.getExtras().getParcelableArrayList(Defaults.Params.IMAGES); Defaults.setupInitialValues(getApplicationContext(), intent); if (!Defaults.ACTIVITY_THEME.isEmpty()) { setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME)); } setupIds(); setContentView(frame_layout); isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE; if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (!Defaults.STATUS_BAR_COLOR.isEmpty()) { window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR)); } window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR)); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { if (!Defaults.BAR_COLOR.isEmpty()) { actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR)); } actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(Defaults.TITLE); } else { Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG); } mRecyclerView = new RecyclerView(TiApplication.getInstance()); mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView.setLayoutManager(new GridLayoutManager(ImageViewerActivity.this, Defaults.GRID_SIZE)); FrameLayout frame_container = (FrameLayout) findViewById(frame_layout_id); frame_container.addView(mRecyclerView); frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR)); adapterSet = new PhotoAdapter(imagesAdapter); mRecyclerView.setAdapter(adapterSet); if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) { mRecyclerView.addItemDecoration(new DividerDecoration()); } setupGlideOptions(); // set glide-options to apply on image }
Example 19
Source File: BaseActivity.java From nono-android with GNU General Public License v3.0 | 4 votes |
protected void themePatch(){ ActionBar actionBar = getSupportActionBar(); if(actionBar!=null){ actionBar.setBackgroundDrawable(new ColorDrawable(ThemeController.getCurrentColor().getMainColor())); } if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.LOLLIPOP) { if ((this instanceof MainActivity)) { try { final CoordinatorLayout layout=((CoordinatorLayout) findViewById(R.id.coordinator)); final View view= findViewById(R.id.fragment_container); if(view !=null){ view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int coordHeight =layout.getHeight(); int viewHeight =view.getHeight(); if((coordHeight-viewHeight)>returnStatusHeight()*2){ return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.getViewTreeObserver().removeOnGlobalLayoutListener(this); } View statusView=new View(BaseActivity.this); statusView.setBackgroundColor(ThemeController.getCurrentColor().getDarkColor()); statusView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, coordHeight-viewHeight)); ((FrameLayout)findViewById(R.id.content_root)).addView(statusView); } }); } }catch (NullPointerException e){ getWindow().setStatusBarColor(ThemeController.getCurrentColor().getDarkColor()); e.printStackTrace(); } } else { getWindow().setStatusBarColor(ThemeController.getCurrentColor().getDarkColor()); } } }
Example 20
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); imagesAdapter = intent.getExtras().getParcelableArrayList(Defaults.Params.IMAGES); Defaults.setupInitialValues(getApplicationContext(), intent); if (!Defaults.ACTIVITY_THEME.isEmpty()) { setTheme(Utils.getR("style." + Defaults.ACTIVITY_THEME)); } setupIds(); setContentView(frame_layout); isShapeCircle = Defaults.SHAPE_CIRCLE == Defaults.SHAPE; if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (!Defaults.STATUS_BAR_COLOR.isEmpty()) { window.setStatusBarColor(TiConvert.toColor(Defaults.STATUS_BAR_COLOR)); } window.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BACKGROUND_COLOR)); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { if (!Defaults.BAR_COLOR.isEmpty()) { actionBar.setBackgroundDrawable(TiConvert.toColorDrawable(Defaults.BAR_COLOR)); } actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(Defaults.TITLE); } else { Log.e(TAG, Defaults.ACTION_BAR_ERROR_MSG); } mRecyclerView = new RecyclerView(TiApplication.getInstance()); mRecyclerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mRecyclerView.setLayoutManager(new GridLayoutManager(ImageViewerActivity.this, Defaults.GRID_SIZE)); FrameLayout frame_container = (FrameLayout) findViewById(frame_layout_id); frame_container.addView(mRecyclerView); frame_container.setBackgroundColor(TiConvert.toColor(Defaults.BACKGROUND_COLOR)); adapterSet = new PhotoAdapter(imagesAdapter); mRecyclerView.setAdapter(adapterSet); if ( (1 == Defaults.SHOW_DIVIDER) && (!isShapeCircle) ) { mRecyclerView.addItemDecoration(new DividerDecoration()); } setupGlideOptions(); // set glide-options to apply on image }