List of usage examples for android.graphics.drawable StateListDrawable setAlpha
@Override public void setAlpha(int alpha)
From source file:net.yanzm.mth.MaterialTabHost.java
/** * add new tab with specified view//from www . j a v a 2 s .co m * * @param view tab view */ public void addTab(View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { view.setBackgroundResource(R.drawable.mth_tab_widget_background_ripple); } else { // create background using colorControlActivated StateListDrawable d = new StateListDrawable(); d.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(colorControlActivated)); d.setAlpha(180); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(d); } else { view.setBackgroundDrawable(d); } } int tabId = tabWidget.getTabCount(); addTab(newTabSpec(String.valueOf(tabId)).setIndicator(view).setContent(android.R.id.tabcontent)); }
From source file:net.yanzm.mth.MaterialTabHost.java
/** * add new tab with title text/* ww w . j a v a 2 s . com*/ * * @param title title text */ public void addTab(CharSequence title) { int layoutId = getLayoutId(type); TextView tv = (TextView) inflater.inflate(layoutId, tabWidget, false); tv.setText(title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { tv.setBackgroundResource(R.drawable.mth_tab_widget_background_ripple); } else { // create background using colorControlActivated StateListDrawable d = new StateListDrawable(); d.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(colorControlActivated)); d.setAlpha(180); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { tv.setBackground(d); } else { tv.setBackgroundDrawable(d); } } int tabId = tabWidget.getTabCount(); addTab(newTabSpec(String.valueOf(tabId)).setIndicator(tv).setContent(android.R.id.tabcontent)); }