use of android.content.res.TypedArray in project platform_frameworks_base by android.
the class FrameworkActionBar method createMenuPopup.
/**
* Creates a Popup and adds it to the content frame. It also adds another {@link FrameLayout} to
* the content frame which shall serve as the new content root.
*/
@Override
public void createMenuPopup() {
if (!isOverflowPopupNeeded()) {
return;
}
DisplayMetrics metrics = mBridgeContext.getMetrics();
MenuBuilder menu = mActionBar.getMenuBuilder();
OverflowMenuAdapter adapter = new OverflowMenuAdapter(menu, mActionBar.getPopupContext());
ListView listView = new ListView(mActionBar.getPopupContext(), null, R.attr.dropDownListViewStyle);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(measureContentWidth(adapter), LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_END);
if (mActionBar.isSplit()) {
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
layoutParams.bottomMargin = getActionBarHeight() + mActionBar.getMenuPopupMargin();
} else {
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
layoutParams.topMargin = getActionBarHeight() + mActionBar.getMenuPopupMargin();
}
layoutParams.setMarginEnd(getPixelValue("5dp", metrics));
listView.setLayoutParams(layoutParams);
listView.setAdapter(adapter);
final TypedArray a = mActionBar.getPopupContext().obtainStyledAttributes(null, R.styleable.PopupWindow, R.attr.popupMenuStyle, 0);
listView.setBackground(a.getDrawable(R.styleable.PopupWindow_popupBackground));
listView.setDivider(a.getDrawable(R.attr.actionBarDivider));
a.recycle();
listView.setElevation(mActionBar.getMenuPopupElevation());
assert mEnclosingLayout != null : "Unable to find view to attach ActionMenuPopup.";
mEnclosingLayout.addView(listView);
}
use of android.content.res.TypedArray in project Android-MaterialRefreshLayout by android-cjj.
the class CircleProgressBar method init.
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0);
final float density = getContext().getResources().getDisplayMetrics().density;
mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT);
mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT);
mColors = new int[] { mProgressColor };
mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1);
mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density));
mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1);
mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1);
mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density));
mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK);
mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false);
mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true);
mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0);
mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100);
int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1);
if (textVisible != 1) {
mIfDrawText = true;
}
mTextPaint = new Paint();
mTextPaint.setStyle(Paint.Style.FILL);
mTextPaint.setColor(mTextColor);
mTextPaint.setTextSize(mTextSize);
mTextPaint.setAntiAlias(true);
a.recycle();
mProgressDrawable = new MaterialProgressDrawable(getContext(), this);
mProgressDrawable.setStartEndTrim(0, (float) 0.75);
super.setImageDrawable(mProgressDrawable);
}
use of android.content.res.TypedArray in project Android-MaterialRefreshLayout by android-cjj.
the class MaterialRefreshLayout method init.
private void init(Context context, AttributeSet attrs, int defstyleAttr) {
if (isInEditMode()) {
return;
}
if (getChildCount() > 1) {
throw new RuntimeException("can only have one child widget");
}
decelerateInterpolator = new DecelerateInterpolator(10);
TypedArray t = context.obtainStyledAttributes(attrs, R.styleable.MaterialRefreshLayout, defstyleAttr, 0);
isOverlay = t.getBoolean(R.styleable.MaterialRefreshLayout_overlay, false);
/**attrs for materialWaveView*/
waveType = t.getInt(R.styleable.MaterialRefreshLayout_wave_height_type, 0);
if (waveType == 0) {
headHeight = DEFAULT_HEAD_HEIGHT;
waveHeight = DEFAULT_WAVE_HEIGHT;
MaterialWaveView.DefaulHeadHeight = DEFAULT_HEAD_HEIGHT;
MaterialWaveView.DefaulWaveHeight = DEFAULT_WAVE_HEIGHT;
} else {
headHeight = hIGHER_HEAD_HEIGHT;
waveHeight = HIGHER_WAVE_HEIGHT;
MaterialWaveView.DefaulHeadHeight = hIGHER_HEAD_HEIGHT;
MaterialWaveView.DefaulWaveHeight = HIGHER_WAVE_HEIGHT;
}
waveColor = t.getColor(R.styleable.MaterialRefreshLayout_wave_color, Color.WHITE);
isShowWave = t.getBoolean(R.styleable.MaterialRefreshLayout_wave_show, true);
/**attrs for circleprogressbar*/
colorsId = t.getResourceId(R.styleable.MaterialRefreshLayout_progress_colors, R.array.material_colors);
colorSchemeColors = context.getResources().getIntArray(colorsId);
showArrow = t.getBoolean(R.styleable.MaterialRefreshLayout_progress_show_arrow, true);
textType = t.getInt(R.styleable.MaterialRefreshLayout_progress_text_visibility, 1);
progressTextColor = t.getColor(R.styleable.MaterialRefreshLayout_progress_text_color, Color.BLACK);
progressValue = t.getInteger(R.styleable.MaterialRefreshLayout_progress_value, 0);
progressMax = t.getInteger(R.styleable.MaterialRefreshLayout_progress_max_value, 100);
showProgressBg = t.getBoolean(R.styleable.MaterialRefreshLayout_progress_show_circle_backgroud, true);
progressBg = t.getColor(R.styleable.MaterialRefreshLayout_progress_backgroud_color, CircleProgressBar.DEFAULT_CIRCLE_BG_LIGHT);
progressSizeType = t.getInt(R.styleable.MaterialRefreshLayout_progress_size_type, 0);
if (progressSizeType == 0) {
progressSize = DEFAULT_PROGRESS_SIZE;
} else {
progressSize = BIG_PROGRESS_SIZE;
}
isLoadMore = t.getBoolean(R.styleable.MaterialRefreshLayout_isLoadMore, false);
t.recycle();
}
use of android.content.res.TypedArray in project platform_frameworks_base by android.
the class AnimatedRotateDrawable method inflate.
@Override
public void inflate(@NonNull Resources r, @NonNull XmlPullParser parser, @NonNull AttributeSet attrs, @Nullable Theme theme) throws XmlPullParserException, IOException {
final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.AnimatedRotateDrawable);
// Inflation will advance the XmlPullParser and AttributeSet.
super.inflate(r, parser, attrs, theme);
updateStateFromTypedArray(a);
verifyRequiredAttributes(a);
a.recycle();
updateLocalState();
}
use of android.content.res.TypedArray in project platform_frameworks_base by android.
the class AnimatedStateListDrawable method parseTransition.
private int parseTransition(@NonNull Resources r, @NonNull XmlPullParser parser, @NonNull AttributeSet attrs, @Nullable Theme theme) throws XmlPullParserException, IOException {
// This allows state list drawable item elements to be themed at
// inflation time but does NOT make them work for Zygote preload.
final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.AnimatedStateListDrawableTransition);
final int fromId = a.getResourceId(R.styleable.AnimatedStateListDrawableTransition_fromId, 0);
final int toId = a.getResourceId(R.styleable.AnimatedStateListDrawableTransition_toId, 0);
final boolean reversible = a.getBoolean(R.styleable.AnimatedStateListDrawableTransition_reversible, false);
Drawable dr = a.getDrawable(R.styleable.AnimatedStateListDrawableTransition_drawable);
a.recycle();
// attributes and extracting states.
if (dr == null) {
int type;
while ((type = parser.next()) == XmlPullParser.TEXT) {
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException(parser.getPositionDescription() + ": <transition> tag requires a 'drawable' attribute or " + "child tag defining a drawable");
}
dr = Drawable.createFromXmlInner(r, parser, attrs, theme);
}
return mState.addTransition(fromId, toId, dr, reversible);
}
Aggregations