Java Code Examples for android.content.res.TypedArray#getResourceId()

The following examples show how to use android.content.res.TypedArray#getResourceId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FontTextView.java    From android-proguards with Apache License 2.0 6 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FontTextView);

    if (a.hasValue(R.styleable.FontTextView_android_textAppearance)) {
        final int textAppearanceId = a.getResourceId(R.styleable
                        .FontTextView_android_textAppearance,
                android.R.style.TextAppearance);
        TypedArray atp = getContext().obtainStyledAttributes(textAppearanceId,
                R.styleable.FontTextAppearance);
        if (atp.hasValue(R.styleable.FontTextAppearance_font)) {
            setFont(atp.getString(R.styleable.FontTextAppearance_font));
        }
        atp.recycle();
    }

    if (a.hasValue(R.styleable.FontTextView_font)) {
        setFont(a.getString(R.styleable.FontTextView_font));
    }
    a.recycle();
}
 
Example 2
Source File: SpecialEffectsSelectorButton.java    From TikTok with Apache License 2.0 6 votes vote down vote up
public SpecialEffectsSelectorButton(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mContext = context;
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.SpecialEffectsSelectorButton,defStyleAttr,0);
    switch (array.getInt(R.styleable.SpecialEffectsSelectorButton_SpecialEffectsTouchMode,0)){
        case 0:
            mTouchMode = TouchMode.TOUCH;
            break;
        case 1:
            mTouchMode = TouchMode.SELECTOR;
            break;
    }
    mDefaultRes = array.getResourceId(R.styleable.SpecialEffectsSelectorButton_SpecialEffectsDefaultRes,0);
    mSelectedRes = array.getResourceId(R.styleable.SpecialEffectsSelectorButton_SpecialEffectsSelectedRes,0);
    mDefaultViewWidth = array.getDimensionPixelOffset(R.styleable.SpecialEffectsSelectorButton_SpecialEffectsDefaultViewWidth, DensityUtils
            .dp2px(50));
    mDefaultViewHeight = array.getDimensionPixelOffset(R.styleable.SpecialEffectsSelectorButton_SpecialEffectsDefaultViewHeight, DensityUtils.dp2px(50));

    init(context);


}
 
Example 3
Source File: ListMenuItemView.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    mContext = context;

    TypedArray a =
        context.obtainStyledAttributes(
            attrs, R.styleable.SherlockMenuView, defStyle, 0);

    mBackground = a.getDrawable(R.styleable.SherlockMenuView_itemBackground);
    mTextAppearance = a.getResourceId(R.styleable.
                                      SherlockMenuView_itemTextAppearance, -1);
    mPreserveIconSpacing = a.getBoolean(
            R.styleable.SherlockMenuView_preserveIconSpacing, false);
    mTextAppearanceContext = context;

    a.recycle();
}
 
Example 4
Source File: OField.java    From hr with GNU Affero General Public License v3.0 5 votes vote down vote up
private void init(Context context, AttributeSet attrs, int defStyleAttr,
                  int defStyleRes) {
    mContext = context;
    if (attrs != null) {
        TypedArray types = mContext.obtainStyledAttributes(attrs,
                R.styleable.OField);
        mField_name = types.getString(R.styleable.OField_fieldName);
        resId = types.getResourceId(R.styleable.OField_iconResource, 0);
        showIcon = types.getBoolean(R.styleable.OField_showIcon, true);
        tint_color = types.getColor(R.styleable.OField_iconTint, 0);
        show_label = types.getBoolean(R.styleable.OField_showLabel, true);
        int type_value = types.getInt(R.styleable.OField_fieldType, 0);
        mType = FieldType.getTypeValue(type_value);

        with_bottom_padding = types.getBoolean(
                R.styleable.OField_withBottomPadding, true);
        with_top_padding = types.getBoolean(
                R.styleable.OField_withTopPadding, true);
        mLabel = types.getString(R.styleable.OField_controlLabel);
        mValue = types.getString(R.styleable.OField_defaultValue);
        mParsePattern = types.getString(R.styleable.OField_parsePattern);
        mValueArrayId = types.getResourceId(
                R.styleable.OField_valueArray, -1);
        mWidgetType = WidgetType.getWidgetType(types.getInt(
                R.styleable.OField_widgetType, -1));
        mWidgetImageSize = types.getDimension(R.styleable.OField_widgetImageSize, -1);
        withPadding = types.getBoolean(R.styleable.OField_withOutSidePadding, true);

        textColor = types.getColor(R.styleable.OField_fieldTextColor, Color.BLACK);
        labelColor = types.getColor(R.styleable.OField_fieldLabelColor, Color.DKGRAY);
        textAppearance = types.getResourceId(R.styleable.OField_fieldTextAppearance, -1);
        labelAppearance = types.getResourceId(R.styleable.OField_fieldLabelTextAppearance, -1);
        textSize = types.getDimension(R.styleable.OField_fieldTextSize, -1);
        labelSize = types.getDimension(R.styleable.OField_fieldLabelSize, -1);
        defaultImage = types.getResourceId(R.styleable.OField_defaultImage, -1);
        types.recycle();
    }
    if (mContext.getClass().getSimpleName().contains("BridgeContext"))
        initControl();
}
 
Example 5
Source File: AbstractMaterialDialogBuilder.java    From AndroidMaterialDialog with Apache License 2.0 5 votes vote down vote up
/**
 * Obtains the background from a specific theme.
 *
 * @param themeResourceId
 *         The resource id of the theme, the background should be obtained from, as an {@link
 *         Integer} value
 */
private void obtainBackground(@StyleRes final int themeResourceId) {
    TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId,
            new int[]{R.attr.materialDialogBackground});
    int resourceId = typedArray.getResourceId(0, 0);

    if (resourceId != 0) {
        setBackground(resourceId);
    } else {
        setBackgroundColor(
                ContextCompat.getColor(getContext(), R.color.dialog_background_light));
    }
}
 
Example 6
Source File: RadioGroupSetting.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
public RadioGroupSetting(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.RadioGroupSetting, defStyleAttr, 0);
    mLayout = attributes.getResourceId(R.styleable.RadioGroupSetting_layout, R.layout.setting_radio_group);
    mDescription = attributes.getString(R.styleable.RadioGroupSetting_description);
    mOptions = attributes.getTextArray(R.styleable.RadioGroupSetting_options);
    mDescriptions = attributes.getTextArray(R.styleable.RadioGroupSetting_descriptions);
    mMargin = attributes.getDimension(R.styleable.RadioGroupSetting_itemMargin, getDefaultMargin());
    int id = attributes.getResourceId(R.styleable.RadioGroupSetting_values, 0);
    try {
        TypedArray array = context.getResources().obtainTypedArray(id);
        if (array.getType(0) == TypedValue.TYPE_STRING) {
            mValues = getResources().getStringArray(id);

        } else if (array.getType(0) == TypedValue.TYPE_INT_HEX ||
                array.getType(0) == TypedValue.TYPE_INT_DEC) {
            int [] values = getResources().getIntArray(id);
            mValues = new Integer[values.length];
            for (int i=0; i<values.length; i++) {
                mValues[i] = values[i];
            }
        }
        array.recycle();

    } catch (Resources.NotFoundException ignored) {

    }
    attributes.recycle();

    initialize(context, attrs, defStyleAttr, mLayout);
}
 
Example 7
Source File: ThemeUtility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getResourceId(int attr) {
    int[] attrs = new int[]{
            attr
    };
    Context context = BeeboApplication.getInstance().getActivity();
    TypedArray ta = context.obtainStyledAttributes(attrs);
    int id = ta.getResourceId(0, 430);
    ta.recycle();
    return id;
}
 
Example 8
Source File: NavigationPreference.java    From AndroidPreferenceActivity with Apache License 2.0 5 votes vote down vote up
/**
 * Obtains the preference's icon from a specific typed array.
 *
 * @param typedArray
 *         The typed array, the icon should be obtained from, as an instance of the class {@link
 *         TypedArray}. The typed array may not be null
 */
private void obtainIcon(@NonNull final TypedArray typedArray) {
    int resourceId =
            typedArray.getResourceId(R.styleable.NavigationPreference_android_icon, -1);

    if (resourceId != -1) {
        Drawable icon = AppCompatResources.getDrawable(getContext(), resourceId);
        setIcon(icon);
    }
}
 
Example 9
Source File: SmarterSwipeRefreshLayout.java    From RecyclerViewTools with Apache License 2.0 5 votes vote down vote up
public SmarterSwipeRefreshLayout(Context context, AttributeSet attrs) {
   super(context, attrs);
   TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SmarterSwipeRefreshLayout);
   targetResId = a.getResourceId(R.styleable.SmarterSwipeRefreshLayout_target, -1);
   appbarLayoutResId = a.getResourceId(R.styleable.SmarterSwipeRefreshLayout_appBarLayout, -1);
   a.recycle();
}
 
Example 10
Source File: SkinCompatTextHelper.java    From Android-skin-support with MIT License 5 votes vote down vote up
public void onSetTextAppearance(Context context, int resId) {
    final TypedArray a = context.obtainStyledAttributes(resId, R.styleable.SkinTextAppearance);
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
        mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
    }
    if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
        mTextColorHintResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
    }
    a.recycle();
    applyTextColorResource();
    applyTextColorHintResource();
}
 
Example 11
Source File: SendButtonTool.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
private static int getThemeResource(Activity activity, int r_attr_name, int r_drawable_def) {
	int[] attrs = {r_attr_name};
	TypedArray ta = activity.getTheme().obtainStyledAttributes(attrs);

	int res = ta.getResourceId(0, r_drawable_def);
	ta.recycle();

	return res;
}
 
Example 12
Source File: FragmentTabHost.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.inflatedId}, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();

    super.setOnTabChangedListener(this);
}
 
Example 13
Source File: LoadingCardView.java    From leanback-extensions with Apache License 2.0 5 votes vote down vote up
private static int getLoadingCardViewStyle(Context context, AttributeSet attrs, int defStyleAttr) {
	int style = attrs == null ? 0 : attrs.getStyleAttribute();

	if (style == 0) {
		TypedArray styledAttrs = context.obtainStyledAttributes(R.styleable.LoadingCardView);
		style = styledAttrs.getResourceId(R.styleable.LoadingCardView_loading_theme, 0);
		styledAttrs.recycle();
	}

	return style;
}
 
Example 14
Source File: FabSpeedDial.java    From fab-speed-dial with Apache License 2.0 5 votes vote down vote up
private void resolveCompulsoryAttributes(TypedArray typedArray) {
    if (typedArray.hasValue(R.styleable.FabSpeedDial_fabMenu)) {
        menuId = typedArray.getResourceId(R.styleable.FabSpeedDial_fabMenu, 0);
    } else {
        throw new AndroidRuntimeException("You must provide the id of the menu resource.");
    }

    if (typedArray.hasValue(R.styleable.FabSpeedDial_fabGravity)) {
        fabGravity = typedArray.getInt(R.styleable.FabSpeedDial_fabGravity, DEFAULT_MENU_POSITION);
    } else {
        throw new AndroidRuntimeException("You must specify the gravity of the Fab.");
    }
}
 
Example 15
Source File: BubbleTab.java    From BubbleTab with Apache License 2.0 4 votes vote down vote up
private void add(TypedArray array, int res) {
    int value = array.getResourceId(res, 0);
    if (value != 0) {
        images.add(value);
    }
}
 
Example 16
Source File: SlidingUpPanelLayout.java    From BlackLight with GNU General Public License v3.0 4 votes vote down vote up
public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    
    if(isInEditMode()) {
        mShadowDrawable = null;
        mScrollTouchSlop = 0;
        mDragHelper = null;
        return;
    }
    
    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) {
                throw new IllegalArgumentException("gravity must be set to either top or bottom");
            }
            mIsSlidingUp = gravity == Gravity.BOTTOM;
        }

        defAttrs.recycle();

        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout);

        if (ta != null) {
            mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_panelHeight, -1);
            mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_shadowHeight, -1);
            mParalaxOffset = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_paralaxOffset, -1);

            mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_flingVelocity, DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_fadeColor, DEFAULT_FADE_COLOR);

            mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1);

            mOverlayContent = ta.getBoolean(R.styleable.SlidingUpPanelLayout_overlay,DEFAULT_OVERLAY_FLAG);
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }
    if (mParalaxOffset == -1) {
        mParalaxOffset = (int) (DEFAULT_PARALAX_OFFSET * density);
    }
    // If the shadow height is zero, don't show the shadow
    if (mShadowHeight > 0) {
        if (mIsSlidingUp) {
            mShadowDrawable = getResources().getDrawable(R.drawable.above_shadow);
        } else {
            mShadowDrawable = getResources().getDrawable(R.drawable.below_shadow);
        }

    } else {
        mShadowDrawable = null;
    }

    setWillNotDraw(false);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(mMinFlingVelocity * density);

    mCanSlide = true;
    mIsSlidingEnabled = true;

    ViewConfiguration vc = ViewConfiguration.get(context);
    mScrollTouchSlop = vc.getScaledTouchSlop();
}
 
Example 17
Source File: CalendarPickerView.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public CalendarPickerView(Context context, AttributeSet attrs) {
    super(context, attrs);

    Resources res = context.getResources();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CalendarPickerView);
    final int bg = a.getColor(R.styleable.CalendarPickerView_android_background,
            res.getColor(R.color.calendar_bg));
    dividerColor = a.getColor(R.styleable.CalendarPickerView_cp_dividerColor,
            res.getColor(R.color.calendar_divider));
    dayBackgroundResId = a.getResourceId(R.styleable.CalendarPickerView_cp_dayBackground,
            R.drawable.calendar_bg_selector);
    dayTextColorResId = a.getResourceId(R.styleable.CalendarPickerView_cp_dayTextColor,
            R.color.calendar_text_selector);
    titleTextColor =
            a.getColor(R.styleable.CalendarPickerView_cp_titleTextColor, R.color.calendar_text_active);
    headerTextColor =
            a.getColor(R.styleable.CalendarPickerView_cp_headerTextColor, R.color.calendar_text_active);
    a.recycle();

    adapter = new MonthAdapter();
    setDivider(null);
    setDividerHeight(0);
    setBackgroundColor(bg);
    setCacheColorHint(bg);
    locale = Locale.getDefault();
    today = Calendar.getInstance(locale);
    minCal = Calendar.getInstance(locale);
    maxCal = Calendar.getInstance(locale);
    monthCounter = Calendar.getInstance(locale);
    monthNameFormat = new SimpleDateFormat(context.getString(R.string.month_name_format), locale);
    weekdayNameFormat = new SimpleDateFormat(context.getString(R.string.day_name_format), locale);
    fullDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);

    if (isInEditMode()) {
        Calendar nextYear = Calendar.getInstance(locale);
        nextYear.add(Calendar.YEAR, 1);

        init(new Date(), nextYear.getTime()) //
                .withSelectedDate(new Date());
    }
}
 
Example 18
Source File: CollapseOnScrollView.java    From CollapseOnScroll with Apache License 2.0 4 votes vote down vote up
private void init(AttributeSet attrs) {
    setVerticalScrollBarEnabled(false);

    mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    mFlinger = new Flinger();
    mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            mFlinger.start((int) velocityY);
            return true;
        }
    });

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.CollapseOnScrollView);
    final int pinnedViewId = typedArray.getResourceId(R.styleable.CollapseOnScrollView_stayVisibleId, -1);
    final int expandOnDragId = typedArray.getResourceId(R.styleable.CollapseOnScrollView_expandOnDragId, -1);
    typedArray.recycle();

    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            if (Build.VERSION.SDK_INT < 16) {
                getViewTreeObserver().removeGlobalOnLayoutListener(this);
            } else {
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }

            if (pinnedViewId >= 0) {
                mPinnedView = findViewById(pinnedViewId);
                mPinnedViewHeight = mPinnedView.getHeight();
            }

            if (expandOnDragId >= 0) {
                mExpandOnDragView = findViewById(expandOnDragId);
                mExpandOnDragHeight = mExpandOnDragView.getHeight();
                mExpandOnDragView.getLayoutParams().height = 0;
            }

            mLv.getLayoutParams().height = getHeight() - mPinnedViewHeight;
        }
    });
}
 
Example 19
Source File: PagerSlidingTabStrip.java    From RefreashTabView with Apache License 2.0 4 votes vote down vote up
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);

	setFillViewport(true);
	setWillNotDraw(false);

	tabsContainer = new LinearLayout(context);
	tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
	tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	addView(tabsContainer);

	DisplayMetrics dm = getResources().getDisplayMetrics();

	scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
	indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
	underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
	dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
	tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
	dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
	tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

	// get system attrs (android:textSize and android:textColor)

	TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

	tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
	tabTextColor = a.getColor(1, tabTextColor);

	a.recycle();

	// get custom attrs

	a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

	indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
	underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
	dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
	indicatorHeight = a
			.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight);
	underlineHeight = a
			.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight);
	dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding);
	tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
	tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId);
	shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
	scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
	textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

	a.recycle();

	rectPaint = new Paint();
	rectPaint.setAntiAlias(true);
	rectPaint.setStyle(Style.FILL);

	dividerPaint = new Paint();
	dividerPaint.setAntiAlias(true);
	dividerPaint.setStrokeWidth(dividerWidth);

	defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

	if (locale == null) {
		locale = getResources().getConfiguration().locale;
	}
}
 
Example 20
Source File: StickyScrollView.java    From MousePaint with MIT License 3 votes vote down vote up
public StickyScrollView(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);
	setup();

	

	TypedArray a = context.obtainStyledAttributes(attrs,
	        R.styleable.StickyScrollView, defStyle, 0);

   		final float density = context.getResources().getDisplayMetrics().density;
   		int defaultShadowHeightInPix = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);

   		mShadowHeight = a.getDimensionPixelSize(
       		R.styleable.StickyScrollView_stuckShadowHeight,
       		defaultShadowHeightInPix);

   			int shadowDrawableRes = a.getResourceId(
       		R.styleable.StickyScrollView_stuckShadowDrawable, -1);

   		if (shadowDrawableRes != -1) {
     			mShadowDrawable = context.getResources().getDrawable(
         			shadowDrawableRes);
   		}

   		a.recycle();

}