List of usage examples for android.content.res TypedArray getInt
public int getInt(@StyleableRes int index, int defValue)
From source file:com.arlib.floatingsearchview.FloatingSearchView.java
private void applyXmlAttributes(AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingSearchView); try {//from w w w . j a va2 s .co m int searchBarWidth = a.getDimensionPixelSize( R.styleable.FloatingSearchView_floatingSearch_searchBarWidth, ViewGroup.LayoutParams.MATCH_PARENT); mQuerySection.getLayoutParams().width = searchBarWidth; mDivider.getLayoutParams().width = searchBarWidth; mSuggestionListContainer.getLayoutParams().width = searchBarWidth; int searchBarLeftMargin = a.getDimensionPixelSize( R.styleable.FloatingSearchView_floatingSearch_searchBarMarginLeft, ATTRS_SEARCH_BAR_MARGIN_DEFAULT); int searchBarTopMargin = a.getDimensionPixelSize( R.styleable.FloatingSearchView_floatingSearch_searchBarMarginTop, ATTRS_SEARCH_BAR_MARGIN_DEFAULT); int searchBarRightMargin = a.getDimensionPixelSize( R.styleable.FloatingSearchView_floatingSearch_searchBarMarginRight, ATTRS_SEARCH_BAR_MARGIN_DEFAULT); LayoutParams querySectionLP = (LayoutParams) mQuerySection.getLayoutParams(); LayoutParams dividerLP = (LayoutParams) mDivider.getLayoutParams(); LinearLayout.LayoutParams suggestListSectionLP = (LinearLayout.LayoutParams) mSuggestionsSection .getLayoutParams(); int cardPadding = Util.dpToPx(CARD_VIEW_TOP_BOTTOM_SHADOW_HEIGHT); querySectionLP.setMargins(searchBarLeftMargin, searchBarTopMargin, searchBarRightMargin, 0); dividerLP.setMargins(searchBarLeftMargin + cardPadding, 0, searchBarRightMargin + cardPadding, ((MarginLayoutParams) mDivider.getLayoutParams()).bottomMargin); suggestListSectionLP.setMargins(searchBarLeftMargin, 0, searchBarRightMargin, 0); mQuerySection.setLayoutParams(querySectionLP); mDivider.setLayoutParams(dividerLP); mSuggestionsSection.setLayoutParams(suggestListSectionLP); setQueryTextSize( a.getDimensionPixelSize(R.styleable.FloatingSearchView_floatingSearch_searchInputTextSize, ATTRS_QUERY_TEXT_SIZE_SP_DEFAULT)); setSearchHint(a.getString(R.styleable.FloatingSearchView_floatingSearch_searchHint)); setShowSearchKey(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showSearchKey, ATTRS_SEARCH_BAR_SHOW_SEARCH_KEY_DEFAULT)); setCloseSearchOnKeyboardDismiss( a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_close_search_on_keyboard_dismiss, ATTRS_DISMISS_ON_KEYBOARD_DISMISS_DEFAULT)); setDismissOnOutsideClick( a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_dismissOnOutsideTouch, ATTRS_DISMISS_ON_OUTSIDE_TOUCH_DEFAULT)); setSuggestionItemTextSize( a.getDimensionPixelSize(R.styleable.FloatingSearchView_floatingSearch_searchSuggestionTextSize, Util.spToPx(ATTRS_SUGGESTION_TEXT_SIZE_SP_DEFAULT))); //noinspection ResourceType mLeftActionMode = a.getInt(R.styleable.FloatingSearchView_floatingSearch_leftActionMode, ATTRS_SEARCH_BAR_LEFT_ACTION_MODE_DEFAULT); if (a.hasValue(R.styleable.FloatingSearchView_floatingSearch_menu)) { mMenuId = a.getResourceId(R.styleable.FloatingSearchView_floatingSearch_menu, -1); } setDimBackground(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_dimBackground, ATTRS_SHOW_DIM_BACKGROUND_DEFAULT)); setShowMoveUpSuggestion(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showMoveSuggestionUp, ATTRS_SHOW_MOVE_UP_SUGGESTION_DEFAULT)); this.mSuggestionSectionAnimDuration = a.getInt( R.styleable.FloatingSearchView_floatingSearch_suggestionsListAnimDuration, ATTRS_SUGGESTION_ANIM_DURATION_DEFAULT); setBackgroundColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_backgroundColor, Util.getColor(getContext(), R.color.background))); setLeftActionIconColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_leftActionColor, Util.getColor(getContext(), R.color.left_action_icon))); setActionMenuOverflowColor( a.getColor(R.styleable.FloatingSearchView_floatingSearch_actionMenuOverflowColor, Util.getColor(getContext(), R.color.overflow_icon_color))); setMenuItemIconColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_menuItemIconColor, Util.getColor(getContext(), R.color.menu_icon_color))); setDividerColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_dividerColor, Util.getColor(getContext(), R.color.divider))); setClearBtnColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_clearBtnColor, Util.getColor(getContext(), R.color.clear_btn_color))); int viewTextColor = a.getColor(R.styleable.FloatingSearchView_floatingSearch_viewTextColor, Util.getColor(getContext(), R.color.dark_gray)); setViewTextColor(viewTextColor); setQueryTextColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_viewSearchInputTextColor, viewTextColor)); setSuggestionsTextColor(a.getColor( R.styleable.FloatingSearchView_floatingSearch_viewSuggestionItemTextColor, viewTextColor)); setHintTextColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_hintTextColor, Util.getColor(getContext(), R.color.hint_color))); setSuggestionRightIconColor( a.getColor(R.styleable.FloatingSearchView_floatingSearch_suggestionRightIconColor, Util.getColor(getContext(), R.color.gray_active_icon))); } finally { a.recycle(); } }
From source file:com.hanbing.library.android.view.CustomTabLayout23.java
public CustomTabLayout23(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Add the TabStrip mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); TypedArray a = context.obtainStyledAttributes(attrs, com.hanbing.library.android.R.styleable.TabLayout, defStyleAttr, com.hanbing.library.android.R.style.Widget_Design_TabLayout); mTabStrip.setSelectedIndicatorHeight( a.getDimensionPixelSize(com.hanbing.library.android.R.styleable.TabLayout_tabIndicatorHeight, 0)); mTabStrip.setSelectedIndicatorColor( a.getColor(com.hanbing.library.android.R.styleable.TabLayout_tabIndicatorColor, 0)); mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a .getDimensionPixelSize(com.hanbing.library.android.R.styleable.TabLayout_tabPadding, 0); mTabPaddingStart = a.getDimensionPixelSize( com.hanbing.library.android.R.styleable.TabLayout_tabPaddingStart, mTabPaddingStart); mTabPaddingTop = a.getDimensionPixelSize(com.hanbing.library.android.R.styleable.TabLayout_tabPaddingTop, mTabPaddingTop);/*from w w w. j ava 2 s . c o m*/ mTabPaddingEnd = a.getDimensionPixelSize(com.hanbing.library.android.R.styleable.TabLayout_tabPaddingEnd, mTabPaddingEnd); mTabPaddingBottom = a.getDimensionPixelSize( com.hanbing.library.android.R.styleable.TabLayout_tabPaddingBottom, mTabPaddingBottom); mTabTextAppearance = a.getResourceId(com.hanbing.library.android.R.styleable.TabLayout_tabTextAppearance, com.hanbing.library.android.R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(mTabTextAppearance, com.hanbing.library.android.R.styleable.TextAppearance); try { mTabTextSize = ta.getDimensionPixelSize( com.hanbing.library.android.R.styleable.TextAppearance_android_textSize, 0); mTabTextColors = ta .getColorStateList(com.hanbing.library.android.R.styleable.TextAppearance_android_textColor); } finally { ta.recycle(); } if (a.hasValue(com.hanbing.library.android.R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColors = a.getColorStateList(com.hanbing.library.android.R.styleable.TabLayout_tabTextColor); } if (a.hasValue(com.hanbing.library.android.R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) final int selected = a.getColor(com.hanbing.library.android.R.styleable.TabLayout_tabSelectedTextColor, 0); mTabTextColors = createColorStateList(mTabTextColors.getDefaultColor(), selected); } mRequestedTabMinWidth = a.getDimensionPixelSize( com.hanbing.library.android.R.styleable.TabLayout_tabMinWidth, INVALID_WIDTH); mRequestedTabMaxWidth = a.getDimensionPixelSize( com.hanbing.library.android.R.styleable.TabLayout_tabMaxWidth, INVALID_WIDTH); mTabBackgroundResId = a.getResourceId(com.hanbing.library.android.R.styleable.TabLayout_tabBackground, 0); mContentInsetStart = a .getDimensionPixelSize(com.hanbing.library.android.R.styleable.TabLayout_tabContentStart, 0); mMode = a.getInt(com.hanbing.library.android.R.styleable.TabLayout_tabMode, MODE_FIXED); mTabGravity = a.getInt(com.hanbing.library.android.R.styleable.TabLayout_tabGravity, GRAVITY_FILL); a.recycle(); // TODO add attr for these final Resources res = getResources(); mTabTextMultiLineSize = spToPx(12);//res.getDimensionPixelSize(R.dimen.design_tab_text_size_2line); mScrollableTabMinWidth = dpToPx(72);//res.getDimensionPixelSize(R.dimen.design_tab_scrollable_min_width); // Now apply the tab mode and gravity applyModeAndGravity(); }
From source file:com.beijing.ocean.multmediademo.view.mytab.TabLayout.java
public TabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // ThemeUtils.checkAppCompatTheme(context); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Add the TabStrip mTabStrip = new SlidingTabStrip(context); super.addView(mTabStrip, 0, new HorizontalScrollView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); TypedArray a = context.obtainStyledAttributes(attrs, android.support.design.R.styleable.TabLayout, defStyleAttr, android.support.design.R.style.Widget_Design_TabLayout); mTabStrip.setSelectedIndicatorHeight( a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabIndicatorHeight, 0)); mTabStrip.setSelectedIndicatorColor( a.getColor(android.support.design.R.styleable.TabLayout_tabIndicatorColor, 0)); mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a .getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPadding, 0); mTabPaddingStart = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingStart, mTabPaddingStart);/*from ww w. j a v a2 s . c o m*/ mTabPaddingTop = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingTop, mTabPaddingTop); mTabPaddingEnd = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingEnd, mTabPaddingEnd); mTabPaddingBottom = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingBottom, mTabPaddingBottom); mTabTextAppearance = a.getResourceId(android.support.design.R.styleable.TabLayout_tabTextAppearance, android.support.design.R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(mTabTextAppearance, android.support.design.R.styleable.TextAppearance); try { mTabTextSize = ta .getDimensionPixelSize(android.support.design.R.styleable.TextAppearance_android_textSize, 0); mTabTextColors = ta .getColorStateList(android.support.design.R.styleable.TextAppearance_android_textColor); } finally { ta.recycle(); } if (a.hasValue(android.support.design.R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColors = a.getColorStateList(android.support.design.R.styleable.TabLayout_tabTextColor); } if (a.hasValue(android.support.design.R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) final int selected = a.getColor(android.support.design.R.styleable.TabLayout_tabSelectedTextColor, 0); mTabTextColors = createColorStateList(mTabTextColors.getDefaultColor(), selected); } mRequestedTabMinWidth = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabMinWidth, INVALID_WIDTH); mRequestedTabMaxWidth = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabMaxWidth, INVALID_WIDTH); mTabBackgroundResId = a.getResourceId(android.support.design.R.styleable.TabLayout_tabBackground, 0); mContentInsetStart = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabContentStart, 0); mMode = a.getInt(android.support.design.R.styleable.TabLayout_tabMode, MODE_FIXED); mTabGravity = a.getInt(android.support.design.R.styleable.TabLayout_tabGravity, GRAVITY_FILL); a.recycle(); // TODO add attr for these final Resources res = getResources(); mTabTextMultiLineSize = res .getDimensionPixelSize(android.support.design.R.dimen.design_tab_text_size_2line); mScrollableTabMinWidth = res .getDimensionPixelSize(android.support.design.R.dimen.design_tab_scrollable_min_width); // Now apply the tab mode and gravity applyModeAndGravity(); }
From source file:com.max.library.view.TabLayout.java
public TabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Add the TabStrip mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); TypedArray a = context.obtainStyledAttributes(attrs, android.support.design.R.styleable.TabLayout, defStyleAttr, android.support.design.R.style.Widget_Design_TabLayout); mTabStrip.setSelectedIndicatorHeight( a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabIndicatorHeight, 0)); mTabStrip.setSelectedIndicatorColor( a.getColor(android.support.design.R.styleable.TabLayout_tabIndicatorColor, 0)); mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a .getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPadding, 0); mTabPaddingStart = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingStart, mTabPaddingStart);// ww w. j a v a2 s . com mTabPaddingTop = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingTop, mTabPaddingTop); mTabPaddingEnd = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingEnd, mTabPaddingEnd); mTabPaddingBottom = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingBottom, mTabPaddingBottom); mTabTextAppearance = a.getResourceId(android.support.design.R.styleable.TabLayout_tabTextAppearance, android.support.design.R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(mTabTextAppearance, android.support.design.R.styleable.TextAppearance); try { mTabTextSize = ta .getDimensionPixelSize(android.support.design.R.styleable.TextAppearance_android_textSize, 0); mTabTextColors = ta .getColorStateList(android.support.design.R.styleable.TextAppearance_android_textColor); } finally { ta.recycle(); } if (a.hasValue(android.support.design.R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColors = a.getColorStateList(android.support.design.R.styleable.TabLayout_tabTextColor); } if (a.hasValue(android.support.design.R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) final int selected = a.getColor(android.support.design.R.styleable.TabLayout_tabSelectedTextColor, 0); mTabTextColors = createColorStateList(mTabTextColors.getDefaultColor(), selected); } mRequestedTabMinWidth = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabMinWidth, INVALID_WIDTH); mRequestedTabMaxWidth = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabMaxWidth, INVALID_WIDTH); mTabBackgroundResId = a.getResourceId(android.support.design.R.styleable.TabLayout_tabBackground, 0); mContentInsetStart = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabContentStart, 0); mMode = a.getInt(android.support.design.R.styleable.TabLayout_tabMode, MODE_FIXED); mTabGravity = a.getInt(android.support.design.R.styleable.TabLayout_tabGravity, GRAVITY_FILL); a.recycle(); // TODO add attr for these final Resources res = getResources(); mTabTextMultiLineSize = res.getDimensionPixelSize(com.max.library.R.dimen.design_tab_text_size_2line); mScrollableTabMinWidth = res.getDimensionPixelSize(com.max.library.R.dimen.design_tab_scrollable_min_width); // Now apply the tab mode and gravity applyModeAndGravity(); }
From source file:com.android.launcher3.Workspace.java
/** * Used to inflate the Workspace from XML. * * @param context The application's context. * @param attrs The attributes set containing the Workspace's customization values. * @param defStyle Unused./*w w w . ja v a2 s. com*/ */ public Workspace(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContentIsRefreshable = false; mOutlineHelper = HolographicOutlineHelper.obtain(context); mDragEnforcer = new DropTarget.DragEnforcer(context); // With workspace, data is available straight from the get-go setDataIsReady(); mLauncher = (Launcher) context; final Resources res = getResources(); mWorkspaceFadeInAdjacentScreens = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile() .shouldFadeAdjacentWorkspaceScreens(); mFadeInAdjacentScreens = false; mWallpaperManager = WallpaperManager.getInstance(context); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mOverviewModeShrinkFactor = grid.getOverviewModeScale(); mCameraDistance = res.getInteger(R.integer.config_cameraDistance); mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1); a.recycle(); setOnHierarchyChangeListener(this); setHapticFeedbackEnabled(false); initWorkspace(); // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(true); setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); }
From source file:android.support.design.widget.RaeTabLayout.java
public RaeTabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Add the TabStrip mTabStrip = new SlidingTabStrip(context); super.addView(mTabStrip, 0, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout, defStyleAttr, R.style.Widget_Design_TabLayout); mTabStrip.setSelectedIndicatorHeight(a.getDimensionPixelSize(R.styleable.TabLayout_tabIndicatorHeight, 0)); mTabStrip.setSelectedIndicatorColor(a.getColor(R.styleable.TabLayout_tabIndicatorColor, 0)); mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a .getDimensionPixelSize(R.styleable.TabLayout_tabPadding, 0); mTabPaddingStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingStart, mTabPaddingStart); mTabPaddingTop = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingTop, mTabPaddingTop); mTabPaddingEnd = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingEnd, mTabPaddingEnd); mTabPaddingBottom = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingBottom, mTabPaddingBottom); mTabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); // rae attrs//from w w w.ja va2 s . co m TypedArray array = context.obtainStyledAttributes(attrs, android.support.design.widget.R.styleable.RaeTabLayout); setIndicatorWidth(array.getDimensionPixelSize( android.support.design.widget.R.styleable.RaeTabLayout_tabIndicatorWidth, 0)); setIndicatorRaduis(array.getDimensionPixelSize( android.support.design.widget.R.styleable.RaeTabLayout_tabIndicatorRadius, 0)); array.recycle(); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(mTabTextAppearance, android.support.v7.appcompat.R.styleable.TextAppearance); try { mTabTextSize = ta.getDimensionPixelSize( android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize, 0); mTabTextColors = ta .getColorStateList(android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor); } finally { ta.recycle(); } if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColors = a.getColorStateList(R.styleable.TabLayout_tabTextColor); } if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) final int selected = a.getColor(R.styleable.TabLayout_tabSelectedTextColor, 0); mTabTextColors = createColorStateList(mTabTextColors.getDefaultColor(), selected); } mRequestedTabMinWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMinWidth, INVALID_WIDTH); mRequestedTabMaxWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMaxWidth, INVALID_WIDTH); mTabBackgroundResId = a.getResourceId(R.styleable.TabLayout_tabBackground, 0); mContentInsetStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabContentStart, 0); mMode = a.getInt(R.styleable.TabLayout_tabMode, MODE_FIXED); mTabGravity = a.getInt(R.styleable.TabLayout_tabGravity, GRAVITY_FILL); a.recycle(); final Resources res = getResources(); mTabTextMultiLineSize = res.getDimensionPixelSize(R.dimen.design_tab_text_size_2line); mScrollableTabMinWidth = res.getDimensionPixelSize(R.dimen.design_tab_scrollable_min_width); // Now apply the tab mode and gravity applyModeAndGravity(); }
From source file:com.gsclub.strategy.ui.view.CustomTabLayout.java
public CustomTabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Add the TabStrip mTabStrip = new SlidingTabStrip(context); super.addView(mTabStrip, 0, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); TypedArray a = context.obtainStyledAttributes(attrs, android.support.design.R.styleable.TabLayout, defStyleAttr, android.support.design.R.style.Widget_Design_TabLayout); mTabStrip.setSelectedIndicatorHeight( a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabIndicatorHeight, 0)); mTabStrip.setSelectedIndicatorColor( a.getColor(android.support.design.R.styleable.TabLayout_tabIndicatorColor, 0)); mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a .getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPadding, 0); mTabPaddingStart = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingStart, mTabPaddingStart);/*from www.ja v a 2s . co m*/ mTabPaddingTop = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingTop, mTabPaddingTop); mTabPaddingEnd = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingEnd, mTabPaddingEnd); mTabPaddingBottom = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabPaddingBottom, mTabPaddingBottom); mTabTextAppearance = a.getResourceId(android.support.design.R.styleable.TabLayout_tabTextAppearance, android.support.design.R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(mTabTextAppearance, android.support.v7.appcompat.R.styleable.TextAppearance); try { mTabTextSize = ta.getDimensionPixelSize( android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize, 0); mTabTextColors = ta .getColorStateList(android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor); } finally { ta.recycle(); } if (a.hasValue(android.support.design.R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColors = a.getColorStateList(android.support.design.R.styleable.TabLayout_tabTextColor); } if (a.hasValue(android.support.design.R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) final int selected = a.getColor(android.support.design.R.styleable.TabLayout_tabSelectedTextColor, 0); mTabTextColors = createColorStateList(mTabTextColors.getDefaultColor(), selected); } mRequestedTabMinWidth = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabMinWidth, INVALID_WIDTH); mRequestedTabMaxWidth = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabMaxWidth, INVALID_WIDTH); mTabBackgroundResId = a.getResourceId(android.support.design.R.styleable.TabLayout_tabBackground, 0); mContentInsetStart = a.getDimensionPixelSize(android.support.design.R.styleable.TabLayout_tabContentStart, 0); mMode = a.getInt(android.support.design.R.styleable.TabLayout_tabMode, MODE_FIXED); mTabGravity = a.getInt(android.support.design.R.styleable.TabLayout_tabGravity, GRAVITY_FILL); a.recycle(); final Resources res = getResources(); mTabTextMultiLineSize = res .getDimensionPixelSize(android.support.design.R.dimen.design_tab_text_size_2line); mScrollableTabMinWidth = res .getDimensionPixelSize(android.support.design.R.dimen.design_tab_scrollable_min_width); // Now apply the tab mode and gravity applyModeAndGravity(); }
From source file:android.content.pm.PackageParser.java
private PermissionGroup parsePermissionGroup(Package owner, int flags, Resources res, XmlPullParser parser, AttributeSet attrs, String[] outError) throws XmlPullParserException, IOException { PermissionGroup perm = new PermissionGroup(owner); TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestPermissionGroup); if (!parsePackageItemInfo(owner, perm.info, outError, "<permission-group>", sa, com.android.internal.R.styleable.AndroidManifestPermissionGroup_name, com.android.internal.R.styleable.AndroidManifestPermissionGroup_label, com.android.internal.R.styleable.AndroidManifestPermissionGroup_icon, com.android.internal.R.styleable.AndroidManifestPermissionGroup_logo, com.android.internal.R.styleable.AndroidManifestPermissionGroup_banner)) { sa.recycle();//ww w .j av a2 s . c o m mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return null; } perm.info.descriptionRes = sa .getResourceId(com.android.internal.R.styleable.AndroidManifestPermissionGroup_description, 0); perm.info.flags = sa .getInt(com.android.internal.R.styleable.AndroidManifestPermissionGroup_permissionGroupFlags, 0); perm.info.priority = sa.getInt(com.android.internal.R.styleable.AndroidManifestPermissionGroup_priority, 0); if (perm.info.priority > 0 && (flags & PARSE_IS_SYSTEM) == 0) { perm.info.priority = 0; } sa.recycle(); if (!parseAllMetaData(res, parser, attrs, "<permission-group>", perm, outError)) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return null; } owner.permissionGroups.add(perm); return perm; }
From source file:android.content.pm.PackageParser.java
private Permission parsePermission(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, String[] outError) throws XmlPullParserException, IOException { Permission perm = new Permission(owner); TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestPermission); if (!parsePackageItemInfo(owner, perm.info, outError, "<permission>", sa, com.android.internal.R.styleable.AndroidManifestPermission_name, com.android.internal.R.styleable.AndroidManifestPermission_label, com.android.internal.R.styleable.AndroidManifestPermission_icon, com.android.internal.R.styleable.AndroidManifestPermission_logo, com.android.internal.R.styleable.AndroidManifestPermission_banner)) { sa.recycle();// w w w . j a va 2 s .com mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return null; } // Note: don't allow this value to be a reference to a resource // that may change. perm.info.group = sa .getNonResourceString(com.android.internal.R.styleable.AndroidManifestPermission_permissionGroup); if (perm.info.group != null) { perm.info.group = perm.info.group.intern(); } perm.info.descriptionRes = sa .getResourceId(com.android.internal.R.styleable.AndroidManifestPermission_description, 0); perm.info.protectionLevel = sa.getInt( com.android.internal.R.styleable.AndroidManifestPermission_protectionLevel, PermissionInfo.PROTECTION_NORMAL); perm.info.flags = sa.getInt(com.android.internal.R.styleable.AndroidManifestPermission_permissionFlags, 0); sa.recycle(); if (perm.info.protectionLevel == -1) { outError[0] = "<permission> does not specify protectionLevel"; mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return null; } perm.info.protectionLevel = PermissionInfo.fixProtectionLevel(perm.info.protectionLevel); if ((perm.info.protectionLevel & PermissionInfo.PROTECTION_MASK_FLAGS) != 0) { if ((perm.info.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE) != PermissionInfo.PROTECTION_SIGNATURE) { outError[0] = "<permission> protectionLevel specifies a flag but is " + "not based on signature type"; mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return null; } } if (!parseAllMetaData(res, parser, attrs, "<permission>", perm, outError)) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return null; } owner.permissions.add(perm); return perm; }
From source file:android.content.pm.PackageParser.java
private Activity parseActivity(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, String[] outError, boolean receiver, boolean hardwareAccelerated) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, R.styleable.AndroidManifestActivity); if (mParseActivityArgs == null) { mParseActivityArgs = new ParseComponentArgs(owner, outError, R.styleable.AndroidManifestActivity_name, R.styleable.AndroidManifestActivity_label, R.styleable.AndroidManifestActivity_icon, R.styleable.AndroidManifestActivity_logo, R.styleable.AndroidManifestActivity_banner, mSeparateProcesses, R.styleable.AndroidManifestActivity_process, R.styleable.AndroidManifestActivity_description, R.styleable.AndroidManifestActivity_enabled); }/*from w ww. j a v a 2 s .com*/ mParseActivityArgs.tag = receiver ? "<receiver>" : "<activity>"; mParseActivityArgs.sa = sa; mParseActivityArgs.flags = flags; Activity a = new Activity(mParseActivityArgs, new ActivityInfo()); if (outError[0] != null) { sa.recycle(); return null; } boolean setExported = sa.hasValue(R.styleable.AndroidManifestActivity_exported); if (setExported) { a.info.exported = sa.getBoolean(R.styleable.AndroidManifestActivity_exported, false); } a.info.theme = sa.getResourceId(R.styleable.AndroidManifestActivity_theme, 0); a.info.uiOptions = sa.getInt(R.styleable.AndroidManifestActivity_uiOptions, a.info.applicationInfo.uiOptions); String parentName = sa.getNonConfigurationString(R.styleable.AndroidManifestActivity_parentActivityName, Configuration.NATIVE_CONFIG_VERSION); if (parentName != null) { String parentClassName = buildClassName(a.info.packageName, parentName, outError); if (outError[0] == null) { a.info.parentActivityName = parentClassName; } else { Log.e(TAG, "Activity " + a.info.name + " specified invalid parentActivityName " + parentName); outError[0] = null; } } String str; str = sa.getNonConfigurationString(R.styleable.AndroidManifestActivity_permission, 0); if (str == null) { a.info.permission = owner.applicationInfo.permission; } else { a.info.permission = str.length() > 0 ? str.toString().intern() : null; } str = sa.getNonConfigurationString(R.styleable.AndroidManifestActivity_taskAffinity, Configuration.NATIVE_CONFIG_VERSION); a.info.taskAffinity = buildTaskAffinityName(owner.applicationInfo.packageName, owner.applicationInfo.taskAffinity, str, outError); a.info.flags = 0; if (sa.getBoolean(R.styleable.AndroidManifestActivity_multiprocess, false)) { a.info.flags |= ActivityInfo.FLAG_MULTIPROCESS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_finishOnTaskLaunch, false)) { a.info.flags |= ActivityInfo.FLAG_FINISH_ON_TASK_LAUNCH; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_clearTaskOnLaunch, false)) { a.info.flags |= ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_noHistory, false)) { a.info.flags |= ActivityInfo.FLAG_NO_HISTORY; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_alwaysRetainTaskState, false)) { a.info.flags |= ActivityInfo.FLAG_ALWAYS_RETAIN_TASK_STATE; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_stateNotNeeded, false)) { a.info.flags |= ActivityInfo.FLAG_STATE_NOT_NEEDED; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_excludeFromRecents, false)) { a.info.flags |= ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_allowTaskReparenting, (owner.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING) != 0)) { a.info.flags |= ActivityInfo.FLAG_ALLOW_TASK_REPARENTING; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_finishOnCloseSystemDialogs, false)) { a.info.flags |= ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_showOnLockScreen, false) || sa.getBoolean(R.styleable.AndroidManifestActivity_showForAllUsers, false)) { a.info.flags |= ActivityInfo.FLAG_SHOW_FOR_ALL_USERS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_immersive, false)) { a.info.flags |= ActivityInfo.FLAG_IMMERSIVE; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_primaryUserOnly, false)) { a.info.flags |= ActivityInfo.FLAG_PRIMARY_USER_ONLY; } if (!receiver) { if (sa.getBoolean(R.styleable.AndroidManifestActivity_hardwareAccelerated, hardwareAccelerated)) { a.info.flags |= ActivityInfo.FLAG_HARDWARE_ACCELERATED; } a.info.launchMode = sa.getInt(R.styleable.AndroidManifestActivity_launchMode, ActivityInfo.LAUNCH_MULTIPLE); a.info.documentLaunchMode = sa.getInt(R.styleable.AndroidManifestActivity_documentLaunchMode, ActivityInfo.DOCUMENT_LAUNCH_NONE); a.info.maxRecents = sa.getInt(R.styleable.AndroidManifestActivity_maxRecents, ActivityManager.getDefaultAppRecentsLimitStatic()); a.info.configChanges = sa.getInt(R.styleable.AndroidManifestActivity_configChanges, 0); a.info.softInputMode = sa.getInt(R.styleable.AndroidManifestActivity_windowSoftInputMode, 0); a.info.persistableMode = sa.getInteger(R.styleable.AndroidManifestActivity_persistableMode, ActivityInfo.PERSIST_ROOT_ONLY); if (sa.getBoolean(R.styleable.AndroidManifestActivity_allowEmbedded, false)) { a.info.flags |= ActivityInfo.FLAG_ALLOW_EMBEDDED; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_autoRemoveFromRecents, false)) { a.info.flags |= ActivityInfo.FLAG_AUTO_REMOVE_FROM_RECENTS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_relinquishTaskIdentity, false)) { a.info.flags |= ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_resumeWhilePausing, false)) { a.info.flags |= ActivityInfo.FLAG_RESUME_WHILE_PAUSING; } a.info.resizeable = sa.getBoolean(R.styleable.AndroidManifestActivity_resizeableActivity, false); if (a.info.resizeable) { // Fixed screen orientation isn't supported with resizeable activities. a.info.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; } else { a.info.screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } a.info.lockTaskLaunchMode = sa.getInt(R.styleable.AndroidManifestActivity_lockTaskMode, 0); } else { a.info.launchMode = ActivityInfo.LAUNCH_MULTIPLE; a.info.configChanges = 0; if (sa.getBoolean(R.styleable.AndroidManifestActivity_singleUser, false)) { a.info.flags |= ActivityInfo.FLAG_SINGLE_USER; if (a.info.exported && (flags & PARSE_IS_PRIVILEGED) == 0) { Slog.w(TAG, "Activity exported request ignored due to singleUser: " + a.className + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); a.info.exported = false; setExported = true; } } } sa.recycle(); if (receiver && (owner.applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) { // A heavy-weight application can not have receives in its main process // We can do direct compare because we intern all strings. if (a.info.processName == owner.packageName) { outError[0] = "Heavy-weight applications can not have receivers in main process"; } } if (outError[0] != null) { return null; } int outerDepth = parser.getDepth(); int type; while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { continue; } if (parser.getName().equals("intent-filter")) { ActivityIntentInfo intent = new ActivityIntentInfo(a); if (!parseIntent(res, parser, attrs, true, true, intent, outError)) { return null; } if (intent.countActions() == 0) { Slog.w(TAG, "No actions in intent filter at " + mArchiveSourcePath + " " + parser.getPositionDescription()); } else { a.intents.add(intent); } } else if (!receiver && parser.getName().equals("preferred")) { ActivityIntentInfo intent = new ActivityIntentInfo(a); if (!parseIntent(res, parser, attrs, false, false, intent, outError)) { return null; } if (intent.countActions() == 0) { Slog.w(TAG, "No actions in preferred at " + mArchiveSourcePath + " " + parser.getPositionDescription()); } else { if (owner.preferredActivityFilters == null) { owner.preferredActivityFilters = new ArrayList<ActivityIntentInfo>(); } owner.preferredActivityFilters.add(intent); } } else if (parser.getName().equals("meta-data")) { if ((a.metaData = parseMetaData(res, parser, attrs, a.metaData, outError)) == null) { return null; } } else { if (!RIGID_PARSER) { Slog.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); if (receiver) { Slog.w(TAG, "Unknown element under <receiver>: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); } else { Slog.w(TAG, "Unknown element under <activity>: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); } XmlUtils.skipCurrentTag(parser); continue; } else { if (receiver) { outError[0] = "Bad element under <receiver>: " + parser.getName(); } else { outError[0] = "Bad element under <activity>: " + parser.getName(); } return null; } } } if (!setExported) { a.info.exported = a.intents.size() > 0; } return a; }