android.util.AttributeSet.getStyleAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中android.util.AttributeSet.getStyleAttribute()方法的一些代码示例,展示了AttributeSet.getStyleAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributeSet.getStyleAttribute()方法的具体详情如下:
包路径:android.util.AttributeSet
类名称:AttributeSet
方法名:getStyleAttribute

AttributeSet.getStyleAttribute介绍

暂无

代码示例

代码示例来源:origin: square/assertj-android

public AttributeSetAssert hasStyleAttribute(int value) {
  isNotNull();
  int actualValue = actual.getStyleAttribute();
  assertThat(actualValue) //
    .overridingErrorMessage("Expected style attribute value <%s> but was <%s>.", value,
      actualValue) //
    .isEqualTo(value);
  return this;
 }
}

代码示例来源:origin: qiujuer/Genius-Android

/**
 * Get Background color if the attr is color value
 *
 * @param context Context
 * @param attrs   AttributeSet
 * @return Color
 */
public static int getBackgroundColor(Context context, AttributeSet attrs) {
  int color = Color.TRANSPARENT;
  if (isHaveAttribute(attrs, "background")) {
    int styleId = attrs.getStyleAttribute();
    int[] attributesArray = new int[]{android.R.attr.background};
    try {
      TypedArray typedArray = context.obtainStyledAttributes(styleId, attributesArray);
      if (typedArray.length() > 0)
        color = typedArray.getColor(0, color);
      typedArray.recycle();
    } catch (Resources.NotFoundException e) {
      e.printStackTrace();
    }
  }
  return color;
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getStyleAttribute_returnsZeroWhenNoStyle() throws Exception {
 AttributeSet roboAttributeSet = Robolectric.buildAttributeSet()
   .build();
 assertThat(roboAttributeSet.getStyleAttribute())
   .isEqualTo(0);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getStyleAttribute_returnsCorrectValue() throws Exception {
 AttributeSet roboAttributeSet = Robolectric.buildAttributeSet()
   .setStyleAttribute("@style/Gastropod")
   .build();
 assertThat(roboAttributeSet.getStyleAttribute())
   .isEqualTo(R.style.Gastropod);
}

代码示例来源:origin: robolectric/robolectric

if (set != null && set.getStyleAttribute() != 0) {
 ResName styleAttributeResName = getResName(set.getStyleAttribute());
 while (styleAttributeResName.type.equals("attr")) {
  AttributeResource attrValue = themeStyleSet.getAttrValue(styleAttributeResName);

代码示例来源:origin: stackoverflow.com

public LoginButton(Context context, AttributeSet attrs) {
  super(context, attrs);

  if (attrs.getStyleAttribute() == 0) {
    do stuff ...
  }
}

代码示例来源:origin: stackoverflow.com

public CustomView(Context context, AttributeSet attrs) {
  this(context, attrs, attrs.getStyleAttribute());
}

代码示例来源:origin: stackoverflow.com

super(context, attrs);
if (attrs.getStyleAttribute() == 0) {

代码示例来源:origin: stackoverflow.com

super(context, attrs);
if (attrs.getStyleAttribute() == 0) {

代码示例来源:origin: hitherejoe/LeanbackCards

private static int getIconCardViewStyle(Context context, AttributeSet attrs, int defStyleAttr) {
  int style = null == attrs ? 0 : attrs.getStyleAttribute();
  if (0 == style) {
    TypedArray styledAttrs =
        context.obtainStyledAttributes(R.styleable.IconCardView);
    style = styledAttrs.getResourceId(R.styleable.IconCardView_icon_theme, 0);
    styledAttrs.recycle();
  }
  return style;
}

代码示例来源:origin: hitherejoe/LeanbackCards

private static int getLoadingCardViewStyle(Context context,
                      AttributeSet attrs,
                      int defStyleAttr) {
  int style = null == attrs ? 0 : attrs.getStyleAttribute();
  if (0 == style) {
    TypedArray styledAttrs =
        context.obtainStyledAttributes(R.styleable.LoadingCardView);
    style = styledAttrs.getResourceId(R.styleable.LoadingCardView_loading_theme, 0);
    styledAttrs.recycle();
  }
  return style;
}

代码示例来源:origin: hitherejoe/LeanbackCards

private static int getTagCardViewStyle(Context context, AttributeSet attrs, int defStyleAttr) {
  int style = null == attrs ? 0 : attrs.getStyleAttribute();
  if (0 == style) {
    TypedArray styledAttrs =
        context.obtainStyledAttributes(R.styleable.TagCardView);
    style = styledAttrs.getResourceId(R.styleable.TagCardView_tag_theme, 0);
    styledAttrs.recycle();
  }
  return style;
}

代码示例来源:origin: hitherejoe/LeanbackCards

private static int getImageCardViewStyle(Context context, AttributeSet attrs, int defStyleAttr) {
  int style = null == attrs ? 0 : attrs.getStyleAttribute();
  if (0 == style) {
    TypedArray styledAttrs = context.obtainStyledAttributes(R.styleable.LiveCardView);
    style = styledAttrs.getResourceId(R.styleable.LiveCardView_live_theme, 0);
    styledAttrs.recycle();
  }
  return style;
}

代码示例来源:origin: sregg/spotify-tv

private static int getImageCardViewStyle(Context context, AttributeSet attrs, int defStyleAttr) {
  int style = null == attrs ? 0 : attrs.getStyleAttribute();
  if (0 == style) {
    TypedArray styledAttrs = context.obtainStyledAttributes(R.styleable.SpotifyCardView);
    style = styledAttrs.getResourceId(R.styleable.SpotifyCardView_spotify_card_theme, 0);
    styledAttrs.recycle();
  }
  return style;
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public AttributeSetAssert hasStyleAttribute(int value) {
  isNotNull();
  int actualValue = actual.getStyleAttribute();
  assertThat(actualValue) //
    .overridingErrorMessage("Expected style attribute value <%s> but was <%s>.", value,
      actualValue) //
    .isEqualTo(value);
  return this;
 }
}

代码示例来源:origin: werbhelius/Werb

/**
 * 加载默认的样式(蓝色)。
 * 
 * @param attrs XML 属性集合对象
 */
private void loadDefaultStyle(AttributeSet attrs) {
  if (attrs != null && 0 == attrs.getStyleAttribute()) {
    Resources res = getResources();
    this.setBackgroundResource(R.drawable.com_sina_weibo_sdk_button_blue);
    this.setPadding(res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_left),
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_top),
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_right),
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_bottom));
    this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_com_sina_weibo_sdk_logo, 0, 0, 0);
    this.setCompoundDrawablePadding(
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_compound_drawable_padding));
    this.setTextColor(res.getColor(R.color.com_sina_weibo_sdk_loginview_text_color));
    this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
        res.getDimension(R.dimen.com_sina_weibo_sdk_loginview_text_size));
    this.setTypeface(Typeface.DEFAULT_BOLD);
    this.setGravity(Gravity.CENTER);
    this.setText(R.string.com_sina_weibo_sdk_login_with_weibo_account);
  }
}

代码示例来源:origin: lytsing/weibo

/**
 * 加载默认的样式(蓝色)。
 * 
 * @param attrs XML 属性集合对象
 */
private void loadDefaultStyle(AttributeSet attrs) {
  if (attrs != null && 0 == attrs.getStyleAttribute()) {
    Resources res = getResources();
    this.setBackgroundResource(R.drawable.com_sina_weibo_sdk_button_blue);
    this.setPadding(res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_left),
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_top),
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_right),
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_bottom));
    this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_com_sina_weibo_sdk_logo, 0, 0, 0);
    this.setCompoundDrawablePadding(
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_compound_drawable_padding));
    this.setTextColor(res.getColor(R.color.com_sina_weibo_sdk_loginview_text_color));
    this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
        res.getDimension(R.dimen.com_sina_weibo_sdk_loginview_text_size));
    this.setTypeface(Typeface.DEFAULT_BOLD);
    this.setGravity(Gravity.CENTER);
    this.setText(R.string.com_sina_weibo_sdk_login_with_weibo_account);
  }
}

代码示例来源:origin: pkhope/weibo

/**
 * 加载默认的样式(蓝色)。
 * 
 * @param attrs XML 属性集合对象
 */
private void loadDefaultStyle(AttributeSet attrs) {
  if (attrs != null && 0 == attrs.getStyleAttribute()) {
    Resources res = getResources();
    this.setBackgroundResource(R.drawable.com_sina_weibo_sdk_button_blue);
    this.setPadding(res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_left),
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_top),
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_right),
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_bottom));
    this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_com_sina_weibo_sdk_logo, 0, 0, 0);
    this.setCompoundDrawablePadding(
        res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_compound_drawable_padding));
    this.setTextColor(res.getColor(R.color.com_sina_weibo_sdk_loginview_text_color));
    this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
        res.getDimension(R.dimen.com_sina_weibo_sdk_loginview_text_size));
    this.setTypeface(Typeface.DEFAULT_BOLD);
    this.setGravity(Gravity.CENTER);
    this.setText(R.string.com_sina_weibo_sdk_login_with_weibo_account);
  }
}

代码示例来源:origin: fr.avianey/facebook-android-api

super(context, attrs);
if (attrs.getStyleAttribute() == 0) {

代码示例来源:origin: org.robolectric/shadows-core-v23

if (set != null && set.getStyleAttribute() != 0) {
 ResName styleAttributeResName = getResName(set.getStyleAttribute());
 while (styleAttributeResName.type.equals("attr")) {
  AttributeResource attrValue = themeStyleSet.getAttrValue(styleAttributeResName);

相关文章