List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable
public ColorDrawable(@ColorInt int color)
From source file:com.caseybrooks.scripturememory.activities.DetailActivity.java
@Override public void setToolBar(String name, int color) { ActionBar ab = getSupportActionBar(); ColorDrawable colorDrawable = new ColorDrawable(color); ab.setBackgroundDrawable(colorDrawable); ab.setTitle(name);//from w ww . j av a 2 s. com ab.setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= 0.8f; // value component getWindow().setStatusBarColor(Color.HSVToColor(hsv)); } }
From source file:com.filemanager.free.activities.DbViewer.java
@Override public void onCreate(Bundle savedInstanceState) { this.checkStorage = false; super.onCreate(savedInstanceState); if (theme1 == 1) { setTheme(R.style.appCompatDark); getWindow().getDecorView()/*from ww w . ja va 2 s.c o m*/ .setBackgroundColor(ContextCompat.getColor(getBaseContext(), R.color.holo_dark_background)); } setContentView(R.layout.activity_db_viewer); toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); skin = PreferenceUtils.getPrimaryColorString(Sp); if (Build.VERSION.SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager", ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(), Color.parseColor(skin)); ((Activity) this).setTaskDescription(taskDescription); } skinStatusBar = PreferenceUtils.getStatusColor(skin); assert (getSupportActionBar()) != null; getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT == 20 || Build.VERSION.SDK_INT == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { boolean colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor((PreferenceUtils.getStatusColor(skin))); if (colourednavigation) window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin))); } String path = getIntent().getStringExtra("path"); pathFile = new File(path); listView = (ListView) findViewById(R.id.listView); load(pathFile); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); DbViewerFragment fragment = new DbViewerFragment(); Bundle bundle = new Bundle(); bundle.putString("table", arrayList.get(position)); fragment.setArguments(bundle); fragmentTransaction.add(R.id.content_frame, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } }); }
From source file:com.jia.blossom.viewpageindicator.MainActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);/* w ww . j a va 2 s. co m*/ if (Build.VERSION.SDK_INT >= 11) { Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { if (Build.VERSION.SDK_INT < 17) { Log.e("lintest", Build.VERSION.SDK_INT + " < 17"); ld.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(ld); } } else { // TransitionDrawableDrawable?drawable? TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); if (Build.VERSION.SDK_INT < 17) { td.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(td); } td.startTransition(3000); } oldBackground = ld; getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(true); } currentColor = newColor; }
From source file:com.igniva.filemanager.activities.DbViewer.java
@Override public void onCreate(Bundle savedInstanceState) { this.checkStorage = false; super.onCreate(savedInstanceState); if (theme1 == 1) { setTheme(R.style.appCompatDark); getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.holo_dark_background)); }// w ww . j a v a 2s . c om setContentView(R.layout.activity_db_viewer); toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (Build.VERSION.SDK_INT >= 21) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Filemanager", ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(), Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin)); ((Activity) this).setTaskDescription(taskDescription); } getSupportActionBar().setBackgroundDrawable( new ColorDrawable(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin))); getSupportActionBar().setDisplayHomeAsUpEnabled(true); int sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { boolean colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(PreferenceUtils.getStatusColor(MainActivity.currentTab == 1 ? skinTwo : skin)); if (colourednavigation) window.setNavigationBarColor( (PreferenceUtils.getStatusColor(MainActivity.currentTab == 1 ? skinTwo : skin))); } path = getIntent().getStringExtra("path"); pathFile = new File(path); listView = (ListView) findViewById(R.id.listView); load(pathFile); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); DbViewerFragment fragment = new DbViewerFragment(); Bundle bundle = new Bundle(); bundle.putString("table", arrayList.get(position)); fragment.setArguments(bundle); fragmentTransaction.add(R.id.content_frame, fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } }); }
From source file:com.example.Dare.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(android.R.color.transparent)); username = (EditText) findViewById(R.id.input_username); // Configure Cast device discovery mMediaRouter = MediaRouter.getInstance(getApplicationContext()); mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory( CastMediaControlIntent.categoryForCast(getResources().getString(R.string.app_id))).build(); mMediaRouterCallback = new MyMediaRouterCallback(); }
From source file:com.haoxue.zixueplayer.MainActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);/* w w w. j a v a 2 s .com*/ // change ActionBar color just if an ActionBar is available if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { getActionBar().setBackgroundDrawable(ld); } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); getActionBar().setBackgroundDrawable(td); td.startTransition(200); } oldBackground = ld; getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(true); } }
From source file:com.charjack.charjackplayer.MainActivity.java
private void changeColor(int newColor) { tabs.setIndicatorColor(newColor);/*from w ww . j a v a 2s. c o m*/ // change ActionBar color just if an ActionBar is available if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { System.out.println("------------1-----"); Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = getResources().getDrawable(R.drawable.actionbar_bottom); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { System.out.println("------------2-----"); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { ld.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(ld); } } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); // workaround for broken ActionBarContainer drawable handling on // pre-API 17 builds // https://github.com/android/platform_frameworks_base/commit/a7cc06d82e45918c37429a59b14545c6a57db4e4 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { td.setCallback(drawableCallback); } else { getActionBar().setBackgroundDrawable(td); } td.startTransition(200); } oldBackground = ld; // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowTitleEnabled(true); } currentColor = newColor; }
From source file:com.example.yeshwanthemani.billpayementapp.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); Button button = (Button) findViewById(R.id.button); scanResults = (TextView) findViewById(R.id.scan_results); if (savedInstanceState != null) { imageUri = Uri.parse(savedInstanceState.getString(SAVED_INSTANCE_URI)); scanResults.setText(savedInstanceState.getString(SAVED_INSTANCE_RESULT)); }/*from w w w . j a va2s . com*/ button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ActivityCompat.requestPermissions(HomeActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_WRITE_PERMISSION); } }); detector = new BarcodeDetector.Builder(getApplicationContext()) .setBarcodeFormats(Barcode.DATA_MATRIX | Barcode.QR_CODE).build(); if (!detector.isOperational()) { scanResults.setText("Could not set up the detector!"); return; } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); android.support.v7.app.ActionBar bar = getSupportActionBar(); if (bar != null) { bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#FF6600"))); bar.setTitle("BillPay"); } NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); }
From source file:com.massivcode.androidmusicplayer.fragments.CurrentPlaylistFragment.java
@Nullable @Override//from ww w. ja va 2s. co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_current_playlist, container, false); getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE)); setCancelable(false); initView(view); return view; }
From source file:com.marshalchen.common.demoofui.pagerSlidingTabStrip.PagerSlidingTabStripActivity.java
private void changeColor(int newColor) { tabs.setBackgroundColor(newColor);// w ww. ja va 2 s . c o m mTintManager.setTintColor(newColor); // change ActionBar color just if an ActionBar is available Drawable colorDrawable = new ColorDrawable(newColor); Drawable bottomDrawable = new ColorDrawable(getResources().getColor(android.R.color.transparent)); LayerDrawable ld = new LayerDrawable(new Drawable[] { colorDrawable, bottomDrawable }); if (oldBackground == null) { getSupportActionBar().setBackgroundDrawable(ld); } else { TransitionDrawable td = new TransitionDrawable(new Drawable[] { oldBackground, ld }); getSupportActionBar().setBackgroundDrawable(td); td.startTransition(200); } oldBackground = ld; currentColor = newColor; }