Example usage for android.content.res TypedArray hasValue

List of usage examples for android.content.res TypedArray hasValue

Introduction

In this page you can find the example usage for android.content.res TypedArray hasValue.

Prototype

public boolean hasValue(@StyleableRes int index) 

Source Link

Document

Determines whether there is an attribute at index.

Usage

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);//www .  j  ava2 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.tengio.FloatingSearchView.java

private void applyXmlAttributes(AttributeSet attrs) {

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingSearchView);

    try {/*from   w w w .ja  v a  2  s. c  o m*/

        int searchBarWidth = a.getDimensionPixelSize(
                R.styleable.FloatingSearchView_floatingSearch_searchBarWidth,
                ViewGroup.LayoutParams.MATCH_PARENT);
        mQuerySection.getLayoutParams().width = searchBarWidth;
        mDivider.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();
        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);
        mQuerySection.setLayoutParams(querySectionLP);
        mDivider.setLayoutParams(dividerLP);

        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));
        //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);
        }
        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)));
        setViewTextColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_viewTextColor,
                Util.getColor(getContext(), R.color.dark_gray)));
        setHintTextColor(a.getColor(R.styleable.FloatingSearchView_floatingSearch_hintTextColor,
                Util.getColor(getContext(), R.color.hint_color)));
        setFont(a.getString(R.styleable.FloatingSearchView_floatingSearch_textFont));
    } finally {
        a.recycle();
    }
}

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   w w w.  j a v  a  2s . 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);/*  w  w  w .j  a  v  a 2 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(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.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 ww w .j  ava  2s . 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.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.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  ww w.j  a v  a2  s  . c o  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.appeaser.sublimepickerlibrary.timepicker.SublimeTimePicker.java

private void initializeLayout() {
    mContext = getContext();// ww w  . j ava 2s. c o  m
    setCurrentLocale(Locale.getDefault());

    // process style attributes
    final TypedArray a = mContext.obtainStyledAttributes(R.styleable.SublimeTimePicker);
    final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final Resources res = mContext.getResources();

    mSelectHours = res.getString(R.string.select_hours);
    mSelectMinutes = res.getString(R.string.select_minutes);

    DateFormatSymbols dfs = DateFormatSymbols.getInstance(mCurrentLocale);
    String[] amPmStrings = dfs.getAmPmStrings();/*{"AM", "PM"}*/

    if (amPmStrings.length == 2 && !TextUtils.isEmpty(amPmStrings[0]) && !TextUtils.isEmpty(amPmStrings[1])) {
        mAmText = amPmStrings[0].length() > 2 ? amPmStrings[0].substring(0, 2) : amPmStrings[0];
        mPmText = amPmStrings[1].length() > 2 ? amPmStrings[1].substring(0, 2) : amPmStrings[1];
    } else {
        // Defaults
        mAmText = "AM";
        mPmText = "PM";
    }

    final int layoutResourceId = R.layout.time_picker_layout;
    final View mainView = inflater.inflate(layoutResourceId, this);

    mHeaderView = mainView.findViewById(R.id.time_header);

    // Set up hour/minute labels.
    mHourView = (TextView) mainView.findViewById(R.id.hours);
    mHourView.setOnClickListener(mClickListener);

    ViewCompat.setAccessibilityDelegate(mHourView, new ClickActionDelegate(mContext, R.string.select_hours));

    mSeparatorView = (TextView) mainView.findViewById(R.id.separator);

    mMinuteView = (TextView) mainView.findViewById(R.id.minutes);
    mMinuteView.setOnClickListener(mClickListener);

    ViewCompat.setAccessibilityDelegate(mMinuteView,
            new ClickActionDelegate(mContext, R.string.select_minutes));

    // Now that we have text appearances out of the way, make sure the hour
    // and minute views are correctly sized.
    mHourView.setMinWidth(computeStableWidth(mHourView, 24));
    mMinuteView.setMinWidth(computeStableWidth(mMinuteView, 60));

    // Set up AM/PM labels.
    mAmPmLayout = mainView.findViewById(R.id.ampm_layout);
    mAmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.am_label);
    mAmLabel.setText(obtainVerbatim(amPmStrings[0]));
    mAmLabel.setOnClickListener(mClickListener);
    mPmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.pm_label);
    mPmLabel.setText(obtainVerbatim(amPmStrings[1]));
    mPmLabel.setOnClickListener(mClickListener);

    ColorStateList headerTextColor = a.getColorStateList(R.styleable.SublimeTimePicker_spHeaderTextColor);

    if (headerTextColor != null) {
        mHourView.setTextColor(headerTextColor);
        mSeparatorView.setTextColor(headerTextColor);
        mMinuteView.setTextColor(headerTextColor);
        mAmLabel.setTextColor(headerTextColor);
        mPmLabel.setTextColor(headerTextColor);
    }

    // Set up header background, if available.
    if (SUtils.isApi_22_OrHigher()) {
        if (a.hasValueOrEmpty(R.styleable.SublimeTimePicker_spHeaderBackground)) {
            SUtils.setViewBackground(mHeaderView,
                    a.getDrawable(R.styleable.SublimeTimePicker_spHeaderBackground));
        }
    } else {
        if (a.hasValue(R.styleable.SublimeTimePicker_spHeaderBackground)) {
            SUtils.setViewBackground(mHeaderView,
                    a.getDrawable(R.styleable.SublimeTimePicker_spHeaderBackground));
        }
    }

    a.recycle();

    mRadialTimePickerView = (RadialTimePickerView) mainView.findViewById(R.id.radial_picker);

    setupListeners();

    mAllowAutoAdvance = true;

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();

    // Initialize with current time
    final Calendar calendar = Calendar.getInstance(mCurrentLocale);
    final int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
    final int currentMinute = calendar.get(Calendar.MINUTE);
    initialize(currentHour, currentMinute, false /* 12h */, HOUR_INDEX);
}

From source file:devlight.io.library.ArcProgressStackView.java

public ArcProgressStackView(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    // Init CPSV/*from  ww  w .  j av  a2s.  co m*/

    // Always draw
    setWillNotDraw(false);
    setLayerType(LAYER_TYPE_SOFTWARE, null);
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);

    // Detect if features available
    mIsFeaturesAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;

    // Retrieve attributes from xml
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArcProgressStackView);
    try {
        setIsAnimated(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_animated, true));
        setIsShadowed(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_shadowed, true));
        setIsRounded(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_rounded, false));
        setIsDragged(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_dragged, false));
        setIsLeveled(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_leveled, false));
        setTypeface(typedArray.getString(R.styleable.ArcProgressStackView_apsv_typeface));
        setTextColor(typedArray.getColor(R.styleable.ArcProgressStackView_apsv_text_color, Color.WHITE));
        setShadowRadius(typedArray.getDimension(R.styleable.ArcProgressStackView_apsv_shadow_radius,
                DEFAULT_SHADOW_RADIUS));
        setShadowDistance(typedArray.getDimension(R.styleable.ArcProgressStackView_apsv_shadow_distance,
                DEFAULT_SHADOW_DISTANCE));
        setShadowAngle(typedArray.getInteger(R.styleable.ArcProgressStackView_apsv_shadow_angle,
                (int) DEFAULT_SHADOW_ANGLE));
        setShadowColor(
                typedArray.getColor(R.styleable.ArcProgressStackView_apsv_shadow_color, DEFAULT_SHADOW_COLOR));
        setAnimationDuration(typedArray.getInteger(R.styleable.ArcProgressStackView_apsv_animation_duration,
                DEFAULT_ANIMATION_DURATION));
        setStartAngle(typedArray.getInteger(R.styleable.ArcProgressStackView_apsv_start_angle,
                (int) DEFAULT_START_ANGLE));
        setSweepAngle(typedArray.getInteger(R.styleable.ArcProgressStackView_apsv_sweep_angle,
                (int) DEFAULT_SWEEP_ANGLE));
        setProgressModelOffset(typedArray.getDimension(R.styleable.ArcProgressStackView_apsv_model_offset,
                DEFAULT_MODEL_OFFSET));
        setModelBgEnabled(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_model_bg_enabled, false));

        // Set orientation
        final int orientationOrdinal = typedArray
                .getInt(R.styleable.ArcProgressStackView_apsv_indicator_orientation, 0);
        setIndicatorOrientation(
                orientationOrdinal == 0 ? IndicatorOrientation.VERTICAL : IndicatorOrientation.HORIZONTAL);

        // Retrieve interpolator
        Interpolator interpolator = null;
        try {
            final int interpolatorId = typedArray
                    .getResourceId(R.styleable.ArcProgressStackView_apsv_interpolator, 0);
            interpolator = interpolatorId == 0 ? null
                    : AnimationUtils.loadInterpolator(context, interpolatorId);
        } catch (Resources.NotFoundException exception) {
            interpolator = null;
            exception.printStackTrace();
        } finally {
            setInterpolator(interpolator);
        }

        // Set animation info if is available
        if (mIsFeaturesAvailable) {
            mProgressAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION);
            mProgressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(final ValueAnimator animation) {
                    mAnimatedFraction = (float) animation.getAnimatedValue();
                    if (mAnimatorUpdateListener != null)
                        mAnimatorUpdateListener.onAnimationUpdate(animation);

                    postInvalidate();
                }
            });
        }

        // Check whether draw width dimension or fraction
        if (typedArray.hasValue(R.styleable.ArcProgressStackView_apsv_draw_width)) {
            final TypedValue drawWidth = new TypedValue();
            typedArray.getValue(R.styleable.ArcProgressStackView_apsv_draw_width, drawWidth);
            if (drawWidth.type == TypedValue.TYPE_DIMENSION)
                setDrawWidthDimension(drawWidth.getDimension(context.getResources().getDisplayMetrics()));
            else
                setDrawWidthFraction(drawWidth.getFraction(MAX_FRACTION, MAX_FRACTION));
        } else
            setDrawWidthFraction(DEFAULT_DRAW_WIDTH_FRACTION);

        // Set preview models
        if (isInEditMode()) {
            String[] preview = null;
            try {
                final int previewId = typedArray
                        .getResourceId(R.styleable.ArcProgressStackView_apsv_preview_colors, 0);
                preview = previewId == 0 ? null : typedArray.getResources().getStringArray(previewId);
            } catch (Exception exception) {
                preview = null;
                exception.printStackTrace();
            } finally {
                if (preview == null)
                    preview = typedArray.getResources().getStringArray(R.array.default_preview);

                final Random random = new Random();
                for (String previewColor : preview)
                    mModels.add(
                            new Model("", random.nextInt((int) MAX_PROGRESS), Color.parseColor(previewColor)));
                measure(mSize, mSize);
            }

            // Set preview model bg color
            mPreviewModelBgColor = typedArray.getColor(R.styleable.ArcProgressStackView_apsv_preview_bg,
                    Color.LTGRAY);
        }
    } finally {
        typedArray.recycle();
    }
}

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  v  a  2 s  .co  m

        setDismissOnOutsideClick(true);

        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();

        querySectionLP.setMargins(searchBarLeftMargin, searchBarTopMargin, searchBarRightMargin, 0);
        dividerLP.setMargins(searchBarLeftMargin, 0, searchBarRightMargin,
                ((MarginLayoutParams) mDivider.getLayoutParams()).bottomMargin);
        suggestListSectionLP.setMargins(searchBarLeftMargin, 0, searchBarRightMargin, 0);

        mQuerySection.setLayoutParams(querySectionLP);
        mDivider.setLayoutParams(dividerLP);
        mSuggestionsSection.setLayoutParams(suggestListSectionLP);

        setSearchHint(a.getString(R.styleable.FloatingSearchView_floatingSearch_searchHint));

        setShowHintWhenNotFocused(
                a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showSearchHintWhenNotFocused,
                        ATTRS_SEARCH_BAR_SHOW_SEARCH_HINT_NOT_FOCUSED_DEFAULT));

        setLeftShowMenu(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showMenuAction,
                ATTRS_SEARCH_BAR_SHOW_MENU_ACTION_DEFAULT));

        setShowVoiceInput(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showVoiceInput,
                ATTRS_SEARCH_BAR_SHOW_VOICE_ACTION_DEFAULT));

        setShowSearchKey(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showSearchKey,
                ATTRS_SEARCH_BAR_SHOW_SEARCH_KEY_DEFAULT));

        setVoiceSearchHint(a.getString(R.styleable.FloatingSearchView_floatingSearch_voiceRecHint));

        setDismissOnOutsideClick(
                a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_dismissOnOutsideTouch,
                        ATTRS_DISMISS_ON_OUTSIDE_TOUCH_DEFAULT));

        setShowOverflowMenu(a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_showOverFlowMenu,
                ATTRS_SHOW_OVERFLOW_MENU_DEFAULT));

        setSuggestionItemTextSize(
                a.getDimensionPixelSize(R.styleable.FloatingSearchView_floatingSearch_searchSuggestionTextSize,
                        Util.spToPx(ATTRS_SUGGESTION_TEXT_SIZE_SP_DEFAULT)));

        if (a.hasValue(R.styleable.FloatingSearchView_floatingSearch_menu)) {
            inflateOverflowMenu(a.getResourceId(R.styleable.FloatingSearchView_floatingSearch_menu, 0));
        }

        setHideOverflowMenuWhenFocused(
                a.getBoolean(R.styleable.FloatingSearchView_floatingSearch_hideOverflowMenuWhenFocused,
                        ATTRS_HIDE_OVERFLOW_MENU_FOCUSED_DEFAULT));

    } finally {

        a.recycle();
    }
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private void applyXmlAttributes(AttributeSet attrs) {

    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FloatingSearchView);

    try {//from w ww  .  j a  va 2s.  c o  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();
    }
}