當前位置: 首頁>>代碼示例>>Java>>正文


Java TypedArray.getLayoutDimension方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:RealMoMo,項目名稱:NestRadioGroup,代碼行數:26,代碼來源:NestRadioGroup.java

示例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;
}
 
開發者ID:jpaijh,項目名稱:TYT,代碼行數:20,代碼來源:ListZoomView.java

示例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;
}
 
開發者ID:jpaijh,項目名稱:TYT,代碼行數:21,代碼來源:PullToZoomLayout.java

示例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();
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:20,代碼來源:ActionBarContextView.java

示例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;
    }
}
 
開發者ID:rcketscientist,項目名稱:ToggleButtons,代碼行數:27,代碼來源:ToggleGroup.java

示例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();
    }
}
 
開發者ID:OmarAflak,項目名稱:Fingerprint,代碼行數:30,代碼來源:Fingerprint.java

示例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;
            }
        }
    };*/
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:35,代碼來源:RichAutoCompleteTextView.java

示例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);
}
 
開發者ID:ZQ7,項目名稱:RoundView,代碼行數:41,代碼來源:RoundRelativeLayout.java

示例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;
    }
}
 
開發者ID:mmb4rn0,項目名稱:RelativeRadioGroup,代碼行數:25,代碼來源:RelativeRadioGroup.java

示例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;
    }
}
 
開發者ID:JackWHLiu,項目名稱:jackknife,代碼行數:25,代碼來源:MultiRadioGroup.java

示例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);

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:78,代碼來源:SmartTabLayout.java

示例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();
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:6,代碼來源:MaxWidthLinearLayout.java

示例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();
    }
}
 
開發者ID:davidmigloz,項目名稱:number-keyboard,代碼行數:67,代碼來源:NumberKeyboard.java

示例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);
}
 
開發者ID:liu-xiao-dong,項目名稱:JD-Test,代碼行數:11,代碼來源:PercentLayoutHelper.java

示例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();
}
 
開發者ID:sjnyag,項目名稱:AnimationWrapLayout,代碼行數:7,代碼來源:AnimationWrapLayout.java


注:本文中的android.content.res.TypedArray.getLayoutDimension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。