List of usage examples for android.content Context getTheme
@ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme();
From source file:ua.pp.rozkladznu.app.ui.tabs.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true);/* w w w. j a v a 2 s . c o m*/ mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout, 0, 0); try { mTabStrip.setPadding((int) a.getDimension(R.styleable.SlidingTabLayout_tabStripMarginLeft, 0), mTabStrip.getPaddingTop(), (int) a.getDimension(R.styleable.SlidingTabLayout_tabStripMarginRight, 0), mTabStrip.getPaddingBottom()); } finally { a.recycle(); } addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }
From source file:com.github.shareme.gwsmaterialuikit.library.mscrollbar.MaterialScrollBar.java
void setUpProps(Context context, AttributeSet attrs) { a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaterialScrollBar, 0, 0); ArrayList<String> missing = new ArrayList<>(); //Ensures that a recyclerView is associated with the bar. if (!a.hasValue(R.styleable.MaterialScrollBar_msb_recyclerView)) { missing.add("recyclerView"); }/* ww w . j ava 2 s .com*/ //Ensures that a preference is expressed for lightOnTouch. if (!a.hasValue(R.styleable.MaterialScrollBar_msb_lightOnTouch)) { missing.add("lightOnTouch"); } if (missing.size() != 0) { throw new CustomExceptions.MissingAttributesException(missing); } }
From source file:com.bitants.wally.views.swipeclearlayout.SwipeClearLayout.java
private void initAttrs(Context context, AttributeSet attrs) { final Resources.Theme theme = context.getTheme(); if (theme != null) { final TypedArray typedArray = theme.obtainStyledAttributes(attrs, R.styleable.SwipeClearLayout, 0, 0); if (typedArray != null) { try { circleTopMargin = (int) typedArray.getDimension(R.styleable.SwipeClearLayout_circleTopMargin, 0);/* www . ja v a2 s. c o m*/ circleColor = typedArray.getColor(R.styleable.SwipeClearLayout_circleColor, CIRCLE_DEFAULT_COLOR); duration = typedArray.getInteger(R.styleable.SwipeClearLayout_duration, DEFAULT_ANIMATION_DURATION); } finally { typedArray.recycle(); } } } }
From source file:com.google.blockly.android.ToolboxFragment.java
@Override public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(context, attrs, savedInstanceState); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ToolboxFragment, 0, 0); try {//ww w . j a va 2 s. c om //noinspection ResourceType mTabEdge = a.getInt(R.styleable.ToolboxFragment_tabEdge, DEFAULT_TAB_EDGE); mRotateTabs = a.getBoolean(R.styleable.ToolboxFragment_rotateTabs, DEFAULT_ROTATE_TABS); } finally { a.recycle(); } // Store values in arguments, so fragment resume works (no inflation during resume). Bundle args = getArguments(); if (args == null) { setArguments(args = new Bundle()); } args.putInt(ARG_TAB_EDGE, mTabEdge); args.putBoolean(ARG_ROTATE_TABS, mRotateTabs); }
From source file:wfa.com.tma.wfa.chips.ChipsView.java
private void initAttr(Context context, AttributeSet attrs) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ChipsView, 0, 0); try {//from w w w . ja va 2 s . c o m mMaxHeight = a.getDimensionPixelSize(R.styleable.ChipsView_cv_max_height, DEFAULT_MAX_HEIGHT); mVerticalSpacing = a.getDimensionPixelSize(R.styleable.ChipsView_cv_vertical_spacing, (int) (DEFAULT_VERTICAL_SPACING * mDensity)); mChipsBgColor = a.getColor(R.styleable.ChipsView_cv_bg_color, ContextCompat.getColor(context, R.color.chip_bg)); mChipsBgColorClicked = a.getColor(R.styleable.ChipsView_cv_bg_color_clicked, ContextCompat.getColor(context, R.color.blue)); mChipsBgColorIndelible = a.getColor(R.styleable.ChipsView_cv_bg_color_indelible, mChipsBgColor); mChipsTextColor = a.getColor(R.styleable.ChipsView_cv_text_color, Color.BLACK); mChipsTextColorClicked = a.getColor(R.styleable.ChipsView_cv_text_color_clicked, Color.WHITE); mChipsTextColorIndelible = a.getColor(R.styleable.ChipsView_cv_text_color_indelible, mChipsTextColor); mChipsPlaceholderTint = a.getColor(R.styleable.ChipsView_cv_icon_placeholder_tint, 0); mChipsDeleteBtnResId = a.getResourceId(R.styleable.ChipsView_cv_icon_delete, R.drawable.ic_chip_close_24dp); mChipsDeleteBtnResColor = a.getResourceId(R.styleable.ChipsView_cv_icon_delete_color, Color.WHITE); mChipsDeleteBtnBgColor = a.getResourceId(R.styleable.ChipsView_cv_icon_delete_bg_color, Color.GRAY); mChipsDeleteBtnBgColorClicked = a.getResourceId(R.styleable.ChipsView_cv_icon_delete_bg_clicked_color, ContextCompat.getColor(context, R.color.mediumBlue)); mChipsHintText = a.getString(R.styleable.ChipsView_cv_text_hint); mChipsMargin = a.getDimensionPixelSize(R.styleable.ChipsView_cv_chips_margin, 0); } finally { a.recycle(); } }
From source file:im.ene.toro.exoplayer.ExoVideoView.java
public ExoVideoView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // By default, TextureView is used for Android 23 and below, and SurfaceView is for the rest boolean useTextureView = context.getResources().getBoolean(R.bool.use_texture_view); if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ExoVideoView, 0, 0); try {/*from w w w . ja va2 s . com*/ int surfaceType = a.getInt(R.styleable.ExoVideoView_tx1_surfaceType, SURFACE_TYPE_DEFAULT); switch (surfaceType) { case SURFACE_TYPE_SURFACE_VIEW: useTextureView = false; break; case SURFACE_TYPE_TEXTURE_VIEW: useTextureView = true; break; case SURFACE_TYPE_DEFAULT: default: // Unchanged, so don't need to execute the line below // useTextureView = context.getResources().getBoolean(R.bool.use_texture_view); break; } resizeMode = a.getInt(R.styleable.ExoVideoView_tx1_resizeMode, RESIZE_MODE_FIXED_WIDTH); } finally { a.recycle(); } } View view = useTextureView ? new TextureView(context) : new SurfaceView(context); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); view.setLayoutParams(params); surfaceView = view; addView(surfaceView, 0); playerListener = new VideoPlayerListener(); SurfaceHelper surfaceHelper = SurfaceHelper.Factory.getInstance(this, surfaceView); surfaceHelper.setupForView(surfaceView); setFocusable(true); setFocusableInTouchMode(true); requestFocus(); }
From source file:com.oprisnik.navdrawer.widget.NavDrawerLayout.java
public NavDrawerLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mEntryList = new ArrayList<NavDrawerEntry>(); mEntryMap = new HashMap<NavDrawerEntry, View>(); mHandler = new Handler(); setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); int color = Utils.getAttrColor(R.attr.colorPrimaryDark, context); setStatusBarBackgroundColor(color);/*from ww w .j av a 2 s . co m*/ TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.NavDrawerLayout, defStyle, 0); try { mHasHeader = a.getBoolean(R.styleable.NavDrawerLayout_hasHeader, mHasHeader); mHeaderLayoutRes = a.getResourceId(R.styleable.NavDrawerLayout_headerLayout, mHeaderLayoutRes); } finally { a.recycle(); } }
From source file:com.ruesga.rview.widget.MergedStatusChart.java
public MergedStatusChart(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setLayerType(View.LAYER_TYPE_SOFTWARE, null); final Resources res = getResources(); mHeightBarPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, res.getDisplayMetrics()); mMinBarWidth = 0f;/*from w ww .j a v a 2s . c om*/ int openColor = Color.DKGRAY; int mergedColor = Color.DKGRAY; int abandonedColor = Color.DKGRAY; int textColor = Color.WHITE; Resources.Theme theme = context.getTheme(); TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.MergedStatusChart, defStyleAttr, 0); int n = a.getIndexCount(); for (int i = 0; i < n; i++) { int attr = a.getIndex(i); switch (attr) { case R.styleable.MergedStatusChart_heightBarPadding: mHeightBarPadding = a.getDimension(attr, mHeightBarPadding); break; case R.styleable.MergedStatusChart_minBarWidth: mMinBarWidth = a.getDimension(attr, mMinBarWidth); break; case R.styleable.MergedStatusChart_openColor: openColor = a.getColor(attr, openColor); break; case R.styleable.MergedStatusChart_mergedColor: mergedColor = a.getColor(attr, mergedColor); break; case R.styleable.MergedStatusChart_abandonedColor: abandonedColor = a.getColor(attr, abandonedColor); break; case R.styleable.MergedStatusChart_statusLabelTextColor: textColor = a.getColor(attr, textColor); break; } } a.recycle(); mOpenPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mOpenPaint.setStyle(Paint.Style.FILL); mMergedPaint = new Paint(mOpenPaint); mAbandonedPaint = new Paint(mOpenPaint); mOpenPaint.setColor(openColor); mMergedPaint.setColor(mergedColor); mAbandonedPaint.setColor(abandonedColor); mLabelPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mLabelPaint.setTextAlign(Paint.Align.LEFT); mLabelPaint.setFakeBoldText(true); mLabelPaint.setColor(textColor); mLabelPaint .setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 10f, res.getDisplayMetrics())); mLabelPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 2f, res.getDisplayMetrics()); Rect bounds = new Rect(); mLabelPaint.getTextBounds("0", 0, 1, bounds); mLabelHeight = bounds.height(); if (getBackground() == null) { setBackgroundColor(Color.TRANSPARENT); } }
From source file:android.support.v7.internal.app.ToolbarActionBar.java
private void ensureListMenuPresenter(Menu menu) { if (mListMenuPresenter == null && (menu instanceof MenuBuilder)) { MenuBuilder mb = (MenuBuilder) menu; Context context = mDecorToolbar.getContext(); final TypedValue outValue = new TypedValue(); final Resources.Theme widgetTheme = context.getResources().newTheme(); widgetTheme.setTo(context.getTheme()); // Apply the panelMenuListTheme widgetTheme.resolveAttribute(R.attr.panelMenuListTheme, outValue, true); if (outValue.resourceId != 0) { widgetTheme.applyStyle(outValue.resourceId, true); } else {// w w w.j a v a 2 s . c o m widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true); } context = new ContextThemeWrapper(context, 0); context.getTheme().setTo(widgetTheme); // Finally create the list menu presenter mListMenuPresenter = new ListMenuPresenter(context, R.layout.abc_list_menu_item_layout); mListMenuPresenter.setCallback(new PanelMenuPresenterCallback()); mb.addMenuPresenter(mListMenuPresenter); } }