List of usage examples for android.content.res ColorStateList ColorStateList
public ColorStateList(int[][] states, @ColorInt int[] colors)
From source file:com.thatkawaiiguy.meleehandbook.adapter.SearchAdapter.java
private void highlight(String search, String originalText, TextView textView) { int startPos = originalText.toLowerCase(Locale.US).indexOf(search.toLowerCase(Locale.US)); int endPos = startPos + search.length(); if (startPos != -1) { Spannable spannable = new SpannableString(originalText); ColorStateList yellowColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { ContextCompat.getColor(mContext, R.color.overscroll_color) }); TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1, yellowColor, null); spannable.setSpan(highlightSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(spannable);//w w w . j ava2s . com } else textView.setText(originalText); }
From source file:com.landenlabs.all_UiDemo.frag.RadioBtnFrag.java
private void addTabBar(RadioGroup tabHolder, float weight, int padding) { final int maxTabs = 4; // tabHolder.removeAllViews(); int[][] states = new int[][] { new int[] { android.R.attr.state_checked }, new int[] {} }; ColorStateList colorStateList = new ColorStateList(states, new int[] { 0xff00ff00, 0x80ff0000 }); RadioGroup.LayoutParams lp = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, weight); /*/*ww w.jav a2 s . c om*/ ViewOutlineProvider outlineBoundary; if (Build.VERSION.SDK_INT >= 21) { outlineBoundary = new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { outline.setRect(0, 0, 200, 60); // view.getMeasuredWidth(), view.getMeasuredHeight()); } }; } */ String[] pageNames = new String[] { "Home", "Map", "Hourly", "Daily" }; int tabCnt = 0; for (String pageName : pageNames) { RadioButton button = new RadioButton(tabHolder.getContext()); String resName = "tab_" + pageName.toLowerCase(); int resID = getResources().getIdentifier(resName, "drawable", this.getContext().getPackageName()); Drawable tabBtnIcon = getResources().getDrawable(resID); if (tabBtnIcon != null) { if (tabBtnIcon != null && Build.VERSION.SDK_INT >= 21) { tabBtnIcon.setTintMode(PorterDuff.Mode.MULTIPLY); tabBtnIcon.setTintList(colorStateList); } else { tabBtnIcon = DrawableCompat.wrap(tabBtnIcon); DrawableCompat.setTintList(tabBtnIcon.mutate(), colorStateList); DrawableCompat.setTintMode(tabBtnIcon.mutate(), PorterDuff.Mode.MULTIPLY); } // tabBtnIcon = tabHolder.getResources().getDrawable(android.R.drawable.btn_radio); if (Build.VERSION.SDK_INT >= 21) { // Hide standard radio button but leave ripple effect button.setButtonDrawable(null); } else { // Hide standard radio button button.setButtonDrawable(new StateListDrawable()); } button.setCompoundDrawablesWithIntrinsicBounds(null, tabBtnIcon, null, null); /* // button.setBackgroundResource(R.drawable.ripple_boarderless); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { button.setCompoundDrawablesWithIntrinsicBounds(null, tabBtnIcon, null, null); // button.setCompoundDrawablesRelativeWithIntrinsicBounds(null, tabBtnIcon, null, null); // tabBtnIcon.setBounds(0, 0, 50, 100); // img.getMinimumWidth(), img.getMinimumHeight()); // button.setCompoundDrawables(null, tabBtnIcon, null, null); } else { button.setCompoundDrawablesWithIntrinsicBounds(null, tabBtnIcon, null, null); } */ button.setBackgroundResource(R.drawable.ripple_boarderless); button.setPadding(padding, padding, padding, padding); button.setGravity(Gravity.CENTER); button.setTextColor(colorStateList); button.setText(pageName); tabHolder.addView(button, lp); if (++tabCnt == maxTabs) break; } } }
From source file:com.materialdesign.view.tab.TabLayout.java
/** * tab/*from ww w . ja v a 2s. c o m*/ * * @param tabTextColorNormal normal * @param tabTextColorSelected selected */ public void setTabTextColors(@ColorRes int tabTextColorNormal, @ColorRes int tabTextColorSelected) { int[][] stats = new int[][] { { android.R.attr.state_selected }, {} }; int[] colors = new int[] { getResources().getColor(tabTextColorSelected), getResources().getColor(tabTextColorNormal) }; mTabTextColorStateList = new ColorStateList(stats, colors); }
From source file:com.danimahardhika.android.helpers.core.ColorHelper.java
public static ColorStateList getColorStateList(@ColorInt int color) { int[][] states = new int[][] { new int[] { android.R.attr.state_pressed }, new int[] { android.R.attr.state_focused }, new int[] {} }; int[] colors = new int[] { ColorHelper.getDarkerColor(color, 0.8f), ColorHelper.getDarkerColor(color, 0.8f), color };/*from w ww . j av a2s .c o m*/ return new ColorStateList(states, colors); }
From source file:com.tafayor.selfcamerashot.taflib.helpers.GraphicsHelper.java
public static ColorStateList getEnableColorStateList(int enabledColor, int disabledColor) { ColorStateList myColorStateList = new ColorStateList( new int[][] { new int[] { -android.R.attr.state_enabled }, new int[] {} }, new int[] { disabledColor, enabledColor, }); return myColorStateList; }
From source file:com.danimahardhika.android.helpers.core.ColorHelper.java
public static ColorStateList getCheckedColorStateList(@ColorInt int unchecked, @ColorInt int checked) { int[][] states = new int[][] { new int[] { -android.R.attr.state_checked }, new int[] { android.R.attr.state_checked }, }; int[] colors = new int[] { unchecked, checked }; return new ColorStateList(states, colors); }
From source file:feifei.dataanalysis.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) { setSwipeBackEnable(false);/* w ww. j a va2s . c o m*/ } ButterKnife.inject(this); tint(); UmengUpdateAgent.update(this); getData(true); mainSwipe.setColorSchemeColors(Color.WHITE); mainSwipe.setOnRefreshListener(new WaveSwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { // url = Tools.URL + "getTodayData"; // loadData(false, "simple"); getData(false); } }); // mainSwipe.setWaveColor(getResources().getColor(R.color.main_green)); mainSwipe.setWaveColor(Color.parseColor("#84ce08")); adapter = new MyPagerAdapter(getSupportFragmentManager()); tabs.setTextColor(new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed }, //pressed new int[] { android.R.attr.state_selected }, // enabled new int[] {} //default }, new int[] { getResources().getColor(R.color.red), getResources().getColor(R.color.red), getResources().getColor(R.color.darkgray2) })); // final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources() // .getDisplayMetrics()); // pager.setPageMargin(pageMargin); pager.setCurrentItem(0); tabs.setBackgroundColor(getResources().getColor(R.color.white)); orderCount.setText(todayCount); orderMoney.setText(todayMoney); storeCount.setText(allStore); allOrderCount.setText("?: " + allCount); allOrderMoney.setText("??: " + allMoney); SharedPreferences sp = getSharedPreferences(MyApplication.KEY_LOGIN_FILE, MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); boolean first = sp.getBoolean(MyApplication.KEY_FIRST, true); if (first) { initHotWords(); editor.putBoolean(MyApplication.KEY_FIRST, false).apply(); } new Handler().postDelayed(new Runnable() { @Override public void run() { AnimUtil.animScaleAlpha(testLayout); testLayout.setVisibility(View.VISIBLE); AnimUtil.animScaleAlpha(allOrderMoney); allOrderMoney.setVisibility(View.VISIBLE); AnimUtil.animScaleAlpha(allOrderCount); allOrderCount.setVisibility(View.VISIBLE); } }, 100); dialogInit(); // MaterialShowcaseView.resetSingleUse(this, "guide"); // MaterialShowcaseView.resetSingleUse(this, "test"); // presentShowcaseSequence(); // presentShowcaseView(2000); // url = Tools.URL + "getTodayData"; // loadData(false, "simple"); // url = Tools.URL + "getMonthData"; // loadData(true, "30"); // presentShowcaseView(1000); }
From source file:com.brandao.tictactoe.gamesettings.GameSettingsFragment.java
@Override public void onViewCreated(View v, @Nullable Bundle savedInstanceState) { ColorStateList red = new ColorStateList( new int[][] { new int[] { -android.R.attr.state_checked }, new int[] { android.R.attr.state_checked } }, new int[] { Color.DKGRAY, ContextCompat.getColor(getActivity(), R.color.tic_tac_toe_red_shadow), }); ColorStateList green = new ColorStateList( new int[][] { new int[] { -android.R.attr.state_checked }, new int[] { android.R.attr.state_checked } }, new int[] { Color.DKGRAY, ContextCompat.getColor(getActivity(), R.color.tic_tac_toe_green_shadow), }); mEasy.setSupportButtonTintList(red); mMed.setSupportButtonTintList(green); mHard.setSupportButtonTintList(red); v.findViewById(R.id.start_tic_tac_toe).setOnClickListener(new OnClickListener() { @Override// www. j a va2 s.c om public void onClick(View arg0) { Feedback.feedback(getActivity(), R.raw.game_over_sound); startTicTacToe(); } }); v.findViewById(R.id.back_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Feedback.feedback(getActivity(), R.raw.blu_dot_clicked); NavUtils.navigateUpFromSameTask(getActivity()); } }); mSetDifficulty.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.set_difficulty_easy: { mGameDifficulty = C.DIFFICULTY_EASY; break; } case R.id.set_difficulty_medium: { mGameDifficulty = C.DIFFICULTY_MEDIUM; break; } case R.id.set_difficulty_hard: { mGameDifficulty = C.DIFFICULTY_HARD; break; } } } }); mSetFirstPlayer.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.set_x_first: { mWhoGoesFirst = C.X_GOES_FIRST; break; } case R.id.set_o_first: { mWhoGoesFirst = C.O_GOES_FIRST; break; } case R.id.set_x_o_random: { mWhoGoesFirst = C.X_O_RANDOM; break; } } } }); setTheme(v); restoreAndSetPrefs(v); }
From source file:com.yutong.axxc.parents.view.common.ActivityUtils.java
/** * ??/*from ww w . jav a 2 s.c om*/ * @return */ public static ColorStateList createSelector(Context context, int pressedColor, int defaultColor) { int statePressed = android.R.attr.state_pressed; int stateFocesed = android.R.attr.state_focused; int[][] state = { { statePressed }, { -statePressed }, { stateFocesed }, { -stateFocesed } }; int color1 = context.getResources().getColor(pressedColor); int color2 = context.getResources().getColor(defaultColor); int color3 = context.getResources().getColor(pressedColor); int color4 = context.getResources().getColor(defaultColor); int[] color = { color1, color2, color3, color4 }; ColorStateList colorStateList = new ColorStateList(state, color); return colorStateList; }
From source file:de.dala.simplenews.utilities.UIUtils.java
public static ColorStateList getColorTextStateList() { ColorStateList colorStateList;//w w w . java 2 s.c o m if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) { colorStateList = new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed }, new int[] { android.R.attr.state_focused }, new int[] { android.R.attr.state_activated }, new int[] { android.R.attr.state_selected }, new int[] {} }, new int[] { Color.WHITE, Color.WHITE, Color.WHITE, Color.WHITE, Color.BLACK }); } else { colorStateList = new ColorStateList(new int[][] { new int[] { android.R.attr.state_pressed }, new int[] { android.R.attr.state_focused }, new int[] { android.R.attr.state_selected }, new int[] {} }, new int[] { Color.WHITE, Color.WHITE, Color.WHITE, Color.BLACK }); } return colorStateList; }