Example usage for android.util AttributeSet getStyleAttribute

List of usage examples for android.util AttributeSet getStyleAttribute

Introduction

In this page you can find the example usage for android.util AttributeSet getStyleAttribute.

Prototype

public int getStyleAttribute();

Source Link

Document

Return the value of the "style" attribute or 0 if there is not one.

Usage

From source file:com.sina.android.weibo.sdk.widget.LoginoutButton.java

/**
 * ??/*w w w  .java2s . c  o m*/
 * 
 * @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);
    }
}

From source file:com.sina.weibo.sdk.widget.LoginButton1.java

/**
 * //from ww  w .  j  a v a  2 s .  c o m
 *
 * @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_withweb);
    }
}

From source file:com.myteammanager.ui.views.LoginButton.java

/**
 * Create the LoginButton by inflating from XML
 *
 * @see View#View(Context, AttributeSet)
 *//*w  ww.j a  va 2 s  .c o m*/
public LoginButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (attrs.getStyleAttribute() == 0) {
        // apparently there's no method of setting a default style in xml,
        // so in case the users do not explicitly specify a style, we need
        // to use sensible defaults.
        this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color));
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimension(R.dimen.com_facebook_loginview_text_size));
        this.setPadding(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_left),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_top),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_right),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_bottom));
        this.setWidth(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_width));
        this.setHeight(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_height));
        this.setGravity(Gravity.CENTER);

        parseAttributes(attrs);
        if (isInEditMode()) {
            // cannot use a drawable in edit mode, so setting the background color instead
            // of a background resource.
            this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue));
            // hardcoding in edit mode as getResources().getString() doesn't seem to work in IntelliJ
            loginText = "Log in";
        } else {
            this.setBackgroundResource(R.drawable.com_facebook_loginbutton_blue);
            initializeActiveSessionWithCachedToken(context);
        }
    }
}

From source file:com.facebook.LoginButton.java

/**
 * Create the LoginButton by inflating from XML
 * //from w  w  w  . j  a v a 2s  . co m
 * @see View#View(Context, AttributeSet)
 */
public LoginButton(Context context, AttributeSet attrs) {
    super(context, attrs);
    if (attrs.getStyleAttribute() == 0) {
        // apparently there's no method of setting a default style in xml,
        // so in case the users do not explicitly specify a style, we need 
        // to use sensible defaults.
        this.setBackgroundResource(R.drawable.com_facebook_loginbutton_blue);
        this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color));
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimension(R.dimen.com_facebook_loginview_text_size));
        this.setPadding(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_left),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_top),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_right),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_bottom));
        this.setWidth(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_width));
        this.setHeight(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_height));
        this.setGravity(Gravity.CENTER);
    }
    parseAttributes(attrs);
    initializeActiveSessionWithCachedToken(context);
}

From source file:com.trk.aboutme.facebook.widget.LoginButton.java

/**
 * Create the LoginButton by inflating from XML
 *
 * @see View#View(Context, AttributeSet)
 *//*  w  w  w . jav  a  2 s .  c o  m*/
public LoginButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (attrs.getStyleAttribute() == 0) {
        // apparently there's no method of setting a default style in xml,
        // so in case the users do not explicitly specify a style, we need
        // to use sensible defaults.
        this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color));
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimension(R.dimen.com_facebook_loginview_text_size));
        this.setPadding(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_left),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_top),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_right),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_bottom));
        this.setWidth(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_width));
        this.setHeight(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_height));
        this.setGravity(Gravity.CENTER);
        if (isInEditMode()) {
            // cannot use a drawable in edit mode, so setting the background color instead
            // of a background resource.
            this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue));
            // hardcoding in edit mode as getResources().getString() doesn't seem to work in IntelliJ
            loginText = "Log in";
        } else {
            this.setBackgroundResource(R.drawable.com_facebook_loginbutton_blue);
        }
    }
    parseAttributes(attrs);
    if (!isInEditMode()) {
        initializeActiveSessionWithCachedToken(context);
    }
}

From source file:m2.android.archetype.example.FacebookSdk.widget.LoginButton.java

/**
 * Create the LoginButton by inflating from XML
 * // w w w .  j av a2  s  . co m
 * @see View#View(Context, AttributeSet)
 */
public LoginButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (attrs.getStyleAttribute() == 0) {
        // apparently there's no method of setting a default style in xml,
        // so in case the users do not explicitly specify a style, we need
        // to use sensible defaults.
        this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color));
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimension(R.dimen.com_facebook_loginview_text_size));
        this.setPadding(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_left),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_top),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_right),
                getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_bottom));
        this.setWidth(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_width));
        this.setHeight(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_height));
        this.setGravity(Gravity.CENTER);

        parseAttributes(attrs);
        if (isInEditMode()) {
            // cannot use a drawable in edit mode, so setting the background
            // color instead
            // of a background resource.
            this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue));
            // hardcoding in edit mode as getResources().getString() doesn't
            // seem to work in IntelliJ
            loginText = "Log in";
        } else {
            this.setBackgroundResource(R.drawable.com_facebook_loginbutton_blue);
            initializeActiveSessionWithCachedToken(context);
        }
    }
}

From source file:com.facebook.widget.ShareButton.java

/**
 * Create the LoginButton by inflating from XML
 * /*from   www  .j  a  v  a2 s.  com*/
 * @see View#View(Context, AttributeSet)
 */
public ShareButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (attrs.getStyleAttribute() == 0) {
        // apparently there's no method of setting a default style in xml,
        // so in case the users do not explicitly specify a style, we need
        // to use sensible defaults.
        this.setGravity(Gravity.CENTER);
        this.setBackgroundResource(R.drawable.icon_share_fb);
    }
    parseAttributes(attrs);
    if (!isInEditMode()) {
        initializeActiveSessionWithCachedToken(context);
    }
}

From source file:com.facebook.widget.ToggleButtonLogin.java

/**
 * Create the LoginButton by inflating from XML
 * /* www .j  av  a  2  s.  co m*/
 * @see View#View(Context, AttributeSet)
 */
public ToggleButtonLogin(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (attrs.getStyleAttribute() == 0) {
        // apparently there's no method of setting a default style in xml,
        // so in case the users do not explicitly specify a style, we need
        // to use sensible defaults.
        // this.setGravity(Gravity.LEFT);
        // this.setTextColor(getResources().getColor(
        // R.color.com_facebook_loginview_text_color));
        // this.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources()
        // .getDimension(R.dimen.com_facebook_loginview_text_size));
        this.setTypeface(Typeface.DEFAULT_BOLD);
        // if (isInEditMode()) {
        // // cannot use a drawable in edit mode, so setting the background
        // // color instead
        // // of a background resource.
        // // this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue));
        // // hardcoding in edit mode as getResources().getString() doesn't
        // // seem to work in IntelliJ
        // loginText = "Log in with Facebook";
        // } else {
        // // this.setBackgroundResource(R.drawable.btn_register_fb);
        // this.setCompoundDrawablesWithIntrinsicBounds(
        // R.drawable.com_facebook_inverse_icon, 0, 0, 0);
        // this.setCompoundDrawablePadding(getResources()
        // .getDimensionPixelSize(
        // R.dimen.com_facebook_loginview_compound_drawable_padding));
        // this.setPadding(
        // getResources().getDimensionPixelSize(
        // R.dimen.com_facebook_loginview_padding_left),
        // getResources().getDimensionPixelSize(
        // R.dimen.com_facebook_loginview_padding_top),
        // getResources().getDimensionPixelSize(
        // R.dimen.com_facebook_loginview_padding_right),
        // getResources().getDimensionPixelSize(
        // R.dimen.com_facebook_loginview_padding_bottom));
        // }
    }
    parseAttributes(attrs);
    if (!isInEditMode()) {
        initializeActiveSessionWithCachedToken(context);
    }
}

From source file:com.facebook.widget.NoBGLoginButton.java

/**
 * Create the LoginButton by inflating from XML
 * //  w  ww  . j av a2 s  . co m
 * @see View#View(Context, AttributeSet)
 */
public NoBGLoginButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (attrs.getStyleAttribute() == 0) {
        // apparently there's no method of setting a default style in xml,
        // so in case the users do not explicitly specify a style, we need
        // to use sensible defaults.
        this.setGravity(Gravity.CENTER);
        this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color));
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimension(R.dimen.com_facebook_loginview_text_size));
        this.setTypeface(Typeface.DEFAULT_BOLD);
        if (isInEditMode()) {
            // cannot use a drawable in edit mode, so setting the background
            // color instead
            // of a background resource.
            // this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue));
            // hardcoding in edit mode as getResources().getString() doesn't
            // seem to work in IntelliJ
            loginText = "Log in with Facebook";
        } else {
            this.setBackgroundResource(android.R.color.white);
            this.setCompoundDrawablePadding(getResources()
                    .getDimensionPixelSize(R.dimen.com_facebook_loginview_compound_drawable_padding));
            this.setPadding(getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_left),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_top),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_right),
                    getResources().getDimensionPixelSize(R.dimen.com_facebook_loginview_padding_bottom));
        }
    }
    parseAttributes(attrs);
    if (!isInEditMode()) {
        initializeActiveSessionWithCachedToken(context);
    }
}

From source file:com.facebook.widget.GiftTransactionButton.java

/**
 * Create the LoginButton by inflating from XML
 * /* ww  w.  j  a  v  a 2  s.  co  m*/
 * @see View#View(Context, AttributeSet)
 */
public GiftTransactionButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (attrs.getStyleAttribute() == 0) {
        // apparently there's no method of setting a default style in xml,
        // so in case the users do not explicitly specify a style, we need
        // to use sensible defaults.
        this.setGravity(Gravity.CENTER);
        this.setTextColor(getResources().getColor(R.color.com_facebook_loginview_text_color));
        this.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                getResources().getDimension(R.dimen.com_facebook_loginview_text_size));
        this.setTypeface(Typeface.DEFAULT_BOLD);
        if (isInEditMode()) {
            // cannot use a drawable in edit mode, so setting the background
            // color instead
            // of a background resource.
            // this.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue));
            // hardcoding in edit mode as getResources().getString() doesn't
            // seem to work in IntelliJ
            loginText = "Log in with Facebook";
        } else {
            this.setBackgroundResource(R.drawable.btn_doiqua);
            this.setCompoundDrawablePadding(getResources()
                    .getDimensionPixelSize(R.dimen.com_facebook_loginview_compound_drawable_padding));
            //            this.setPadding(
            //                  getResources().getDimensionPixelSize(
            //                        R.dimen.com_facebook_loginview_padding_left),
            //                  getResources().getDimensionPixelSize(
            //                        R.dimen.com_facebook_loginview_padding_top),
            //                  getResources().getDimensionPixelSize(
            //                        R.dimen.com_facebook_loginview_padding_right),
            //                  getResources().getDimensionPixelSize(
            //                        R.dimen.com_facebook_loginview_padding_bottom));
        }
    }
    parseAttributes(attrs);
    if (!isInEditMode()) {
        initializeActiveSessionWithCachedToken(context);
    }
}