Java Code Examples for android.content.res.TypedArray#getLayoutDimension()
The following examples show how to use
android.content.res.TypedArray#getLayoutDimension() .
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: XRadioGroup.java From InteractiveChart with Apache License 2.0 | 6 votes |
/** * <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; } }
Example 2
Source File: ActionBarContextView.java From CSipSimple with GNU General Public License v3.0 | 6 votes |
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(); }
Example 3
Source File: MaterialRadioGroup.java From MaterialRadioGroup with Apache License 2.0 | 6 votes |
/** * <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; } }
Example 4
Source File: XmRadioGroup.java From NewXmPluginSDK with Apache License 2.0 | 6 votes |
/** * <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; } }
Example 5
Source File: BeautyBoxGroup.java From sealrtc-android with MIT License | 6 votes |
/** * 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. * * @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; } }
Example 6
Source File: ToolButtonGroup.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 6 votes |
/** * <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; } }
Example 7
Source File: RelativeRadioGroup.java From libcommon with Apache License 2.0 | 6 votes |
/** * <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; } }
Example 8
Source File: LimitLayout.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 初始化 * @param context {@link Context} * @param attrs {@link AttributeSet} */ private void initAttrs(Context context, AttributeSet attrs) { if (context != null && attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DevWidget); mMaxWidth = a.getLayoutDimension(R.styleable.DevWidget_dev_maxWidth, WidgetUtils.DEF_VALUE); mMaxHeight = a.getLayoutDimension(R.styleable.DevWidget_dev_maxHeight, WidgetUtils.DEF_VALUE); a.recycle(); } }
Example 9
Source File: CustomRecyclerView.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 初始化 * @param context {@link Context} * @param attrs {@link AttributeSet} */ private void initAttrs(Context context, AttributeSet attrs) { if (context != null && attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DevWidget); mIsSlide = a.getBoolean(R.styleable.DevWidget_dev_slide, true); mMaxWidth = a.getLayoutDimension(R.styleable.DevWidget_dev_maxWidth, WidgetUtils.DEF_VALUE); mMaxHeight = a.getLayoutDimension(R.styleable.DevWidget_dev_maxHeight, WidgetUtils.DEF_VALUE); a.recycle(); } }
Example 10
Source File: CustomGallery.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 初始化 * @param context {@link Context} * @param attrs {@link AttributeSet} */ private void initAttrs(Context context, AttributeSet attrs) { if (context != null && attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DevWidget); mIsSlide = a.getBoolean(R.styleable.DevWidget_dev_slide, true); mMaxWidth = a.getLayoutDimension(R.styleable.DevWidget_dev_maxWidth, WidgetUtils.DEF_VALUE); mMaxHeight = a.getLayoutDimension(R.styleable.DevWidget_dev_maxHeight, WidgetUtils.DEF_VALUE); a.recycle(); } }
Example 11
Source File: Fingerprint.java From Fingerprint with MIT License | 5 votes |
@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(); } }
Example 12
Source File: CustomScrollView.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 初始化 * @param context {@link Context} * @param attrs {@link AttributeSet} */ private void initAttrs(Context context, AttributeSet attrs) { if (context != null && attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DevWidget); mIsSlide = a.getBoolean(R.styleable.DevWidget_dev_slide, true); mMaxWidth = a.getLayoutDimension(R.styleable.DevWidget_dev_maxWidth, WidgetUtils.DEF_VALUE); mMaxHeight = a.getLayoutDimension(R.styleable.DevWidget_dev_maxHeight, WidgetUtils.DEF_VALUE); a.recycle(); } }
Example 13
Source File: PlusMinusNum.java From K-Sonic with MIT License | 5 votes |
public PlusMinusNum(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); //layout xmlns:app="http://schemas.android.com/apk/res-auto" //values attrs declare-styleable TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PlusMinusNum); minimumNumValue = typedArray.getFloat(R.styleable.PlusMinusNum_minimumNumValue, 0.1f); maximumNumValue = typedArray.getFloat(R.styleable.PlusMinusNum_maximumNumValue, 2.0f); num = typedArray.getFloat(R.styleable.PlusMinusNum_numValue, 1.0f); buttonWidth = typedArray.getLayoutDimension(R.styleable.PlusMinusNum_buttonWidth, dpToPx(38f));//getResources().getDimension(R.dimen.buttonWidthDefault) ediTextMinimumWidth = typedArray.getLayoutDimension(R.styleable.PlusMinusNum_ediTextMinimumWidth, dpToPx(45f)); typedArray.recycle(); initialize(); }
Example 14
Source File: XanderPanel.java From XanderPanel with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WindowManager.LayoutParams params = getWindow().getAttributes(); TypedArray a = getContext().obtainStyledAttributes(new int[]{android.R.attr.layout_width}); try { params.width = a.getLayoutDimension(0, ViewGroup.LayoutParams.MATCH_PARENT); } finally { a.recycle(); } getWindow().setAttributes(params); }
Example 15
Source File: IcsSpinner.java From Libraries-for-Android-Developers with MIT License | 4 votes |
/** * Construct a new spinner with the given context's theme, the supplied attribute set, * and default style. * * @param context The Context the view is running in, through which it can * access the current theme, resources, etc. * @param attrs The attributes of the XML tag that is inflating the view. * @param defStyle The default style to apply to this view. If 0, no style * will be applied (beyond what is included in the theme). This may * either be an attribute resource, whose value will be retrieved * from the current theme, or an explicit style resource. */ public IcsSpinner(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockSpinner, defStyle, 0); DropdownPopup popup = new DropdownPopup(context, attrs, defStyle); mDropDownWidth = a.getLayoutDimension( R.styleable.SherlockSpinner_android_dropDownWidth, ViewGroup.LayoutParams.WRAP_CONTENT); popup.setBackgroundDrawable(a.getDrawable( R.styleable.SherlockSpinner_android_popupBackground)); final int verticalOffset = a.getDimensionPixelOffset( R.styleable.SherlockSpinner_android_dropDownVerticalOffset, 0); if (verticalOffset != 0) { popup.setVerticalOffset(verticalOffset); } final int horizontalOffset = a.getDimensionPixelOffset( R.styleable.SherlockSpinner_android_dropDownHorizontalOffset, 0); if (horizontalOffset != 0) { popup.setHorizontalOffset(horizontalOffset); } mPopup = popup; mGravity = a.getInt(R.styleable.SherlockSpinner_android_gravity, Gravity.CENTER); mPopup.setPromptText(a.getString(R.styleable.SherlockSpinner_android_prompt)); mDisableChildrenWhenDisabled = true; a.recycle(); // Base constructor can call setAdapter before we initialize mPopup. // Finish setting things up if this happened. if (mTempAdapter != null) { mPopup.setAdapter(mTempAdapter); mTempAdapter = null; } }
Example 16
Source File: IcsSpinner.java From CSipSimple with GNU General Public License v3.0 | 4 votes |
/** * Construct a new spinner with the given context's theme, the supplied attribute set, * and default style. * * @param context The Context the view is running in, through which it can * access the current theme, resources, etc. * @param attrs The attributes of the XML tag that is inflating the view. * @param defStyle The default style to apply to this view. If 0, no style * will be applied (beyond what is included in the theme). This may * either be an attribute resource, whose value will be retrieved * from the current theme, or an explicit style resource. */ public IcsSpinner(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockSpinner, defStyle, 0); DropdownPopup popup = new DropdownPopup(context, attrs, defStyle); mDropDownWidth = a.getLayoutDimension( R.styleable.SherlockSpinner_android_dropDownWidth, ViewGroup.LayoutParams.WRAP_CONTENT); popup.setBackgroundDrawable(a.getDrawable( R.styleable.SherlockSpinner_android_popupBackground)); final int verticalOffset = a.getDimensionPixelOffset( R.styleable.SherlockSpinner_android_dropDownVerticalOffset, 0); if (verticalOffset != 0) { popup.setVerticalOffset(verticalOffset); } final int horizontalOffset = a.getDimensionPixelOffset( R.styleable.SherlockSpinner_android_dropDownHorizontalOffset, 0); if (horizontalOffset != 0) { popup.setHorizontalOffset(horizontalOffset); } mPopup = popup; mGravity = a.getInt(R.styleable.SherlockSpinner_android_gravity, Gravity.CENTER); mPopup.setPromptText(a.getString(R.styleable.SherlockSpinner_android_prompt)); mDisableChildrenWhenDisabled = true; a.recycle(); // Base constructor can call setAdapter before we initialize mPopup. // Finish setting things up if this happened. if (mTempAdapter != null) { mPopup.setAdapter(mTempAdapter); mTempAdapter = null; } }
Example 17
Source File: GridLayout.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override protected void setBaseAttributes(TypedArray attributes, int widthAttr, int heightAttr) { this.width = attributes.getLayoutDimension(widthAttr, DEFAULT_WIDTH); this.height = attributes.getLayoutDimension(heightAttr, DEFAULT_HEIGHT); }
Example 18
Source File: PercentLayoutHelper.java From FimiX8-RE with MIT License | 4 votes |
public static void fetchWidthAndHeight(LayoutParams params, TypedArray array, int widthAttr, int heightAttr) { params.width = array.getLayoutDimension(widthAttr, 0); params.height = array.getLayoutDimension(heightAttr, 0); }
Example 19
Source File: PercentLayoutHelper.java From JD-Test with Apache License 2.0 | 4 votes |
/** * 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); }
Example 20
Source File: TableLayout.java From android_9.0.0_r45 with Apache License 2.0 | 3 votes |
/** * <p>Fixes the row's width to * {@link android.view.ViewGroup.LayoutParams#MATCH_PARENT}; the row's * height is fixed to * {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT} if no layout * height is specified.</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) { this.width = MATCH_PARENT; if (a.hasValue(heightAttr)) { this.height = a.getLayoutDimension(heightAttr, "layout_height"); } else { this.height = WRAP_CONTENT; } }