本文整理汇总了Java中android.content.res.TypedArray.getLayoutDimension方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.getLayoutDimension方法的具体用法?Java TypedArray.getLayoutDimension怎么用?Java TypedArray.getLayoutDimension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.getLayoutDimension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBaseAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* <p>Fixes the child's width to
* {@link ViewGroup.LayoutParams#WRAP_CONTENT} and the child's
* height to {@link ViewGroup.LayoutParams#WRAP_CONTENT}
* when not specified in the XML file.</p>
*
* @param a the styled attributes set
* @param widthAttr the width attribute to fetch
* @param heightAttr the height attribute to fetch
*/
@Override
protected void setBaseAttributes(TypedArray a, int widthAttr, int heightAttr) {
if (a.hasValue(widthAttr)) {
width = a.getLayoutDimension(widthAttr, "layout_width");
} else {
width = WRAP_CONTENT;
}
if (a.hasValue(heightAttr)) {
height = a.getLayoutDimension(heightAttr, "layout_height");
} else {
height = WRAP_CONTENT;
}
}
示例2: ListZoomView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ListZoomView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.pull);
int layout = a.getResourceId(R.styleable.pull_header, 0);
maxHeaderHeight = a.getLayoutDimension(R.styleable.pull_maxHeaderHeight, 0);
int minHeaderHeight = a.getLayoutDimension(R.styleable.pull_minHeaderHeight, 0);
a.recycle();
if (layout == 0) {
throw new RuntimeException("ListZoomView haven't header view.");
}
if (maxHeaderHeight == 0) {
throw new RuntimeException("ListZoomView maxHeaderHeight must be set.");
}
headerView = LayoutInflater.from(context).inflate(layout, null);
addHeaderView(headerView,minHeaderHeight);
currentHeaderHeight = headerHeight;
}
示例3: PullToZoomLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public PullToZoomLayout(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.pull);
int layout = a.getResourceId(R.styleable.pull_header, 0);
maxHeight = a.getLayoutDimension(R.styleable.pull_maxHeaderHeight, 0);
int minHeight = a.getLayoutDimension(R.styleable.pull_minHeaderHeight, 0);
a.recycle();
if (layout == 0) {
throw new RuntimeException("PullToZoomLayout haven't header view.");
}
if (maxHeight == 0) {
throw new RuntimeException("PullToZoomLayout maxHeight must be set.");
}
headerView = LayoutInflater.from(context).inflate(layout, null);
addHeaderView(headerView, minHeight);
headerHeight = getHeaderHeight();
currentHeight = headerHeight;
headerShowing = true;
}
示例4: ActionBarContextView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ActionBarContextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionMode, defStyle, 0);
setBackgroundDrawable(a.getDrawable(
R.styleable.SherlockActionMode_background));
mTitleStyleRes = a.getResourceId(
R.styleable.SherlockActionMode_titleTextStyle, 0);
mSubtitleStyleRes = a.getResourceId(
R.styleable.SherlockActionMode_subtitleTextStyle, 0);
mContentHeight = a.getLayoutDimension(
R.styleable.SherlockActionMode_height, 0);
mSplitBackground = a.getDrawable(
R.styleable.SherlockActionMode_backgroundSplit);
a.recycle();
}
示例5: setBaseAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* <p>Fixes the child's width to
* {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} and the child's
* height to {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT}
* when not specified in the XML file.</p>
*
* @param a the styled attributes set
* @param widthAttr the width attribute to fetch
* @param heightAttr the height attribute to fetch
*/
@Override
protected void setBaseAttributes(TypedArray a,
int widthAttr, int heightAttr) {
if (a.hasValue(widthAttr)) {
width = a.getLayoutDimension(widthAttr, "layout_width");
} else {
width = WRAP_CONTENT;
}
if (a.hasValue(heightAttr)) {
height = a.getLayoutDimension(heightAttr, "layout_height");
} else {
height = WRAP_CONTENT;
}
}
示例6: initAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
@SuppressLint("ResourceType")
private void initAttributes(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes){
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.Fingerprint, defStyleAttr, defStyleRes);
try {
fingerprintScanning = a.getResourceId(R.styleable.Fingerprint_fingerprintScanningColor, R.color.fingerprint_scanning);
fingerprintSuccess = a.getResourceId(R.styleable.Fingerprint_fingerprintSuccessColor, R.color.fingerprint_success);
fingerprintError = a.getResourceId(R.styleable.Fingerprint_fingerprintErrorColor, R.color.fingerprint_error);
circleScanning = a.getResourceId(R.styleable.Fingerprint_circleScanningColor, R.color.circle_scanning);
circleSuccess = a.getResourceId(R.styleable.Fingerprint_circleSuccessColor, R.color.circle_success);
circleError = a.getResourceId(R.styleable.Fingerprint_circleErrorColor, R.color.circle_error);
} finally {
a.recycle();
}
int[] systemAttrs = {android.R.attr.layout_width, android.R.attr.layout_height};
TypedArray ta = context.obtainStyledAttributes(attrs, systemAttrs);
try {
int width = ta.getLayoutDimension(0, ViewGroup.LayoutParams.WRAP_CONTENT);
int height = ta.getLayoutDimension(1, ViewGroup.LayoutParams.WRAP_CONTENT);
if(width==-2 || height==-2) {
size = dipToPixels(DEFAULT_CIRCLE_SIZE);
} else{
size = width;
}
} finally {
ta.recycle();
}
}
示例7: RichAutoCompleteTextView
import android.content.res.TypedArray; //导入方法依赖的package包/类
public RichAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RichAutoCompleteTextView, defStyleAttr,0);
mDropdownLayoutId = a.getResourceId(R.styleable.RichAutoCompleteTextView_dropdown_layout_id,NO_ID);
mImeVisible = a.getBoolean(R.styleable.RichAutoCompleteTextView_ime_visible,true);
if (a.hasValue(R.styleable.RichAutoCompleteTextView_popHeight)) {
mPopHeight = a.getLayoutDimension(R.styleable.RichAutoCompleteTextView_popHeight, "popHeight");
}
if (a.hasValue(R.styleable.RichAutoCompleteTextView_popWidth)) {
mPopWidth = a.getLayoutDimension(R.styleable.RichAutoCompleteTextView_popWidth, "popWidth");
}
a.recycle();
setFocusable(true);
addTextChangedListener(new MyWatcher());
setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
return false;
}
});
/*mHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what){
case SHOW_POP:
break;
case DISMISS_POP:
break;
}
}
};*/
}
示例8: initView
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void initView(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundLatout);
//显示类型
int shapeTpe = a.getInt(R.styleable.RoundLatout_viewShapeTpe, shapeTypes[0]);
//圆角大小
float cornerRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewCornerRadius, 0);
float topLeftRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewTopLeftRadius, 0);
float topRightRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewTopRightRadius, 0);
float bottomLeftRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewBottomLeftRadius, 0);
float bottomRightRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewBottomRightRadius, 0);
//填充色
int solidColor = a.getColor(R.styleable.RoundLatout_viewSolidColor, 0x0);
//边框
int strokeColor = a.getColor(R.styleable.RoundLatout_viewStrokeColor, 0x0);
int strokeWidth = a.getDimensionPixelSize(R.styleable.RoundLatout_viewStrokeWidth, 0);
int strokeDashWidth = a.getDimensionPixelSize(R.styleable.RoundLatout_viewStrokeDashWidth, 0);
int strokeDashGap = a.getDimensionPixelSize(R.styleable.RoundLatout_viewStrokeDashGap, 0);
a.recycle();
GradientDrawable gd = new GradientDrawable();
gd.setColor(solidColor);
//设置类型
gd.setShape(shapeTypes[shapeTpe]);
//类型为矩形才可设置圆角
if (shapeTypes[shapeTpe] == GradientDrawable.RECTANGLE) {
if (cornerRadius != 0) {
gd.setCornerRadius(cornerRadius);
} else {
gd.setCornerRadii(new float[]{topLeftRadius, topLeftRadius, topRightRadius, topRightRadius, bottomRightRadius, bottomRightRadius, bottomLeftRadius, bottomLeftRadius});
}
}
gd.setStroke(strokeWidth, strokeColor, strokeDashWidth, strokeDashGap);
setBackground(gd);
}
示例9: setBaseAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* <p>Fixes the child's width to
* {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} and the child's
* height to {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT}
* when not specified in the XML file.</p>
*
* @param a the styled attributes set
* @param widthAttr the width attribute to fetch
* @param heightAttr the height attribute to fetch
*/
@Override
protected void setBaseAttributes(TypedArray a, int widthAttr, int heightAttr) {
if (a.hasValue(widthAttr)) {
width = a.getLayoutDimension(widthAttr, "layout_width");
} else {
width = WRAP_CONTENT;
}
if (a.hasValue(heightAttr)) {
height = a.getLayoutDimension(heightAttr, "layout_height");
} else {
height = WRAP_CONTENT;
}
}
示例10: setBaseAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* <p>Fixes the child's width to
* {@link ViewGroup.LayoutParams#WRAP_CONTENT} and the child's
* height to {@link ViewGroup.LayoutParams#WRAP_CONTENT}
* when not specified in the XML file.</p>
*
* @param a the styled attributes set
* @param widthAttr the width attribute to fetch
* @param heightAttr the height attribute to fetch
*/
@Override
protected void setBaseAttributes(TypedArray a,
int widthAttr, int heightAttr) {
if (a.hasValue(widthAttr)) {
width = a.getLayoutDimension(widthAttr, "layout_width");
} else {
width = WRAP_CONTENT;
}
if (a.hasValue(heightAttr)) {
height = a.getLayoutDimension(heightAttr, "layout_height");
} else {
height = WRAP_CONTENT;
}
}
示例11: SmartTabLayout
import android.content.res.TypedArray; //导入方法依赖的package包/类
public SmartTabLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// Disable the Scroll Bar
setHorizontalScrollBarEnabled(false);
final DisplayMetrics dm = getResources().getDisplayMetrics();
final float density = dm.density;
int tabBackgroundResId = NO_ID;
boolean textAllCaps = TAB_VIEW_TEXT_ALL_CAPS;
ColorStateList textColors;
float textSize = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP, dm);
int textHorizontalPadding = (int) (TAB_VIEW_PADDING_DIPS * density);
int textMinWidth = (int) (TAB_VIEW_TEXT_MIN_WIDTH * density);
boolean distributeEvenly = DEFAULT_DISTRIBUTE_EVENLY;
int customTabLayoutId = NO_ID;
int customTabTextViewId = NO_ID;
boolean clickable = TAB_CLICKABLE;
int titleOffset = (int) (TITLE_OFFSET_DIPS * density);
TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.stl_SmartTabLayout, defStyle, 0);
tabBackgroundResId = a.getResourceId(
R.styleable.stl_SmartTabLayout_stl_defaultTabBackground, tabBackgroundResId);
textAllCaps = a.getBoolean(
R.styleable.stl_SmartTabLayout_stl_defaultTabTextAllCaps, textAllCaps);
textColors = a.getColorStateList(
R.styleable.stl_SmartTabLayout_stl_defaultTabTextColor);
textSize = a.getDimension(
R.styleable.stl_SmartTabLayout_stl_defaultTabTextSize, textSize);
textHorizontalPadding = a.getDimensionPixelSize(
R.styleable.stl_SmartTabLayout_stl_defaultTabTextHorizontalPadding, textHorizontalPadding);
textMinWidth = a.getDimensionPixelSize(
R.styleable.stl_SmartTabLayout_stl_defaultTabTextMinWidth, textMinWidth);
customTabLayoutId = a.getResourceId(
R.styleable.stl_SmartTabLayout_stl_customTabTextLayoutId, customTabLayoutId);
customTabTextViewId = a.getResourceId(
R.styleable.stl_SmartTabLayout_stl_customTabTextViewId, customTabTextViewId);
distributeEvenly = a.getBoolean(
R.styleable.stl_SmartTabLayout_stl_distributeEvenly, distributeEvenly);
clickable = a.getBoolean(
R.styleable.stl_SmartTabLayout_stl_clickable, clickable);
titleOffset = a.getLayoutDimension(
R.styleable.stl_SmartTabLayout_stl_titleOffset, titleOffset);
a.recycle();
this.titleOffset = titleOffset;
this.tabViewBackgroundResId = tabBackgroundResId;
this.tabViewTextAllCaps = textAllCaps;
this.tabViewTextColors = (textColors != null)
? textColors
: ColorStateList.valueOf(TAB_VIEW_TEXT_COLOR);
this.tabViewTextSize = textSize;
this.tabViewTextHorizontalPadding = textHorizontalPadding;
this.tabViewTextMinWidth = textMinWidth;
this.internalTabClickListener = clickable ? new InternalTabClickListener() : null;
this.distributeEvenly = distributeEvenly;
if (customTabLayoutId != NO_ID) {
setCustomTabView(customTabLayoutId, customTabTextViewId);
}
this.tabStrip = new SmartTabStrip(context, attrs);
if (distributeEvenly && tabStrip.isIndicatorAlwaysInCenter()) {
throw new UnsupportedOperationException(
"'distributeEvenly' and 'indicatorAlwaysInCenter' both use does not support");
}
// Make sure that the Tab Strips fills this View
setFillViewport(!tabStrip.isIndicatorAlwaysInCenter());
addView(tabStrip, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
示例12: init
import android.content.res.TypedArray; //导入方法依赖的package包/类
public void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
mMaxWidth = a.getLayoutDimension(0, Integer.MAX_VALUE);
a.recycle();
}
示例13: initializeAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Initializes XML attributes.
*/
private void initializeAttributes(AttributeSet attrs) {
TypedArray array = getContext().getTheme().obtainStyledAttributes(
attrs, R.styleable.NumberKeyboard, 0, 0);
try {
// Get keyboard type
int type = array.getInt(R.styleable.NumberKeyboard_keyboardType, -1);
if (type == -1) {
throw new IllegalArgumentException("keyboardType attribute is required.");
}
// Get key sizes
keyWidth = array.getLayoutDimension(R.styleable.NumberKeyboard_keyWidth,
dpToPx(DEFAULT_KEY_WIDTH_DP));
keyHeight = array.getLayoutDimension(R.styleable.NumberKeyboard_keyHeight,
dpToPx(DEFAULT_KEY_HEIGHT_DP));
// Get number key background
numberKeyBackground = array.getResourceId(R.styleable.NumberKeyboard_numberKeyBackground,
R.drawable.key_bg);
// Get number key text size
numberKeyTextSize = array.getDimensionPixelSize(R.styleable.NumberKeyboard_numberKeyTextSize,
spToPx(DEFAULT_KEY_TEXT_SIZE_SP));
// Get number key text color
numberKeyTextColor = array.getResourceId(R.styleable.NumberKeyboard_numberKeyTextColor,
R.drawable.key_text_color);
// Get auxiliary icons
switch (type) {
case 0: // integer
leftAuxBtnIcon = R.drawable.key_bg_transparent;
rightAuxBtnIcon = R.drawable.ic_backspace;
leftAuxBtnBackground = R.drawable.key_bg_transparent;
rightAuxBtnBackground = R.drawable.key_bg_transparent;
break;
case 1: // decimal
leftAuxBtnIcon = R.drawable.ic_comma;
rightAuxBtnIcon = R.drawable.ic_backspace;
leftAuxBtnBackground = R.drawable.key_bg;
rightAuxBtnBackground = R.drawable.key_bg_transparent;
break;
case 2: // fingerprint
leftAuxBtnIcon = R.drawable.ic_fingerprint;
rightAuxBtnIcon = R.drawable.ic_backspace;
leftAuxBtnBackground = R.drawable.key_bg_transparent;
rightAuxBtnBackground = R.drawable.key_bg_transparent;
break;
case 3: // custom
leftAuxBtnIcon = array.getResourceId(R.styleable.NumberKeyboard_leftAuxBtnIcon,
R.drawable.key_bg_transparent);
rightAuxBtnIcon = array.getResourceId(R.styleable.NumberKeyboard_rightAuxBtnIcon,
R.drawable.key_bg_transparent);
leftAuxBtnBackground = array.getResourceId(R.styleable.NumberKeyboard_leftAuxBtnBackground,
R.drawable.key_bg_transparent);
rightAuxBtnBackground = array.getResourceId(R.styleable.NumberKeyboard_rightAuxBtnBackground,
R.drawable.key_bg_transparent);
break;
default:
leftAuxBtnIcon = R.drawable.key_bg_transparent;
rightAuxBtnIcon = R.drawable.key_bg_transparent;
leftAuxBtnBackground = R.drawable.key_bg;
rightAuxBtnBackground = R.drawable.key_bg;
}
} finally {
array.recycle();
}
}
示例14: fetchWidthAndHeight
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Helper method to be called from {@link ViewGroup.LayoutParams#setBaseAttributes} override
* that reads layout_width and layout_height attribute values without throwing an exception if
* they aren't present.
*/
public static void fetchWidthAndHeight(ViewGroup.LayoutParams params, TypedArray array,
int widthAttr, int heightAttr) {
params.width = array.getLayoutDimension(widthAttr, 0);
params.height = array.getLayoutDimension(heightAttr, 0);
}
示例15: readAttr
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void readAttr(Context context, AttributeSet attrs) {
TypedArray parameters = context.obtainStyledAttributes(attrs, R.styleable.animation_wrap_layout);
mEachMarginWidth = parameters.getLayoutDimension(R.styleable.animation_wrap_layout_each_margin_width, 4);
mEachMarginHeight = parameters.getLayoutDimension(R.styleable.animation_wrap_layout_each_margin_height, 4);
parameters.recycle();
}