Example usage for android.util TypedValue COMPLEX_UNIT_PX

List of usage examples for android.util TypedValue COMPLEX_UNIT_PX

Introduction

In this page you can find the example usage for android.util TypedValue COMPLEX_UNIT_PX.

Prototype

int COMPLEX_UNIT_PX

To view the source code for android.util TypedValue COMPLEX_UNIT_PX.

Click Source Link

Document

#TYPE_DIMENSION complex unit: Value is raw pixels.

Usage

From source file:com.agenmate.lollipop.util.ViewUtils.java

/**
 * Recursive binary search to find the best size for the text.
 *
 * Adapted from https://github.com/grantland/android-autofittextview
 *///from  w w  w. jav  a 2s  .co  m
public static float getSingleLineTextSize(String text, TextPaint paint, float targetWidth, float low,
        float high, float precision, DisplayMetrics metrics) {
    final float mid = (low + high) / 2.0f;

    paint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, mid, metrics));
    final float maxLineWidth = paint.measureText(text);

    if ((high - low) < precision) {
        return low;
    } else if (maxLineWidth > targetWidth) {
        return getSingleLineTextSize(text, paint, targetWidth, low, mid, precision, metrics);
    } else if (maxLineWidth < targetWidth) {
        return getSingleLineTextSize(text, paint, targetWidth, mid, high, precision, metrics);
    } else {
        return mid;
    }
}

From source file:com.boha.malengagolf.library.util.PagerTitleStrip22.java

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

    addView(mPrevText = new TextView(context));
    addView(mCurrText = new TextView(context));
    addView(mNextText = new TextView(context));

    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    final int textAppearance = a.getResourceId(0, 0);
    if (textAppearance != 0) {
        mPrevText.setTextAppearance(context, textAppearance);
        mCurrText.setTextAppearance(context, textAppearance);
        mNextText.setTextAppearance(context, textAppearance);
    }// w ww  .  j  av  a2 s.  c  o  m
    final int textSize = a.getDimensionPixelSize(1, 0);
    if (textSize != 0) {
        setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    }
    if (a.hasValue(2)) {
        final int textColor = a.getColor(2, 0);
        mPrevText.setTextColor(textColor);
        mCurrText.setTextColor(textColor);
        mNextText.setTextColor(textColor);
    }
    mGravity = a.getInteger(3, Gravity.BOTTOM);
    a.recycle();

    mTextColor = mCurrText.getTextColors().getDefaultColor();
    setNonPrimaryAlpha(SIDE_ALPHA);

    mPrevText.setEllipsize(TruncateAt.END);
    mCurrText.setEllipsize(TruncateAt.END);
    mNextText.setEllipsize(TruncateAt.END);

    boolean allCaps = false;
    if (textAppearance != 0) {
        final TypedArray ta = context.obtainStyledAttributes(textAppearance, TEXT_ATTRS);
        allCaps = ta.getBoolean(0, false);
        ta.recycle();
    }

    if (allCaps) {
        setSingleLineAllCaps(mPrevText);
        setSingleLineAllCaps(mCurrText);
        setSingleLineAllCaps(mNextText);
    } else {
        mPrevText.setSingleLine();
        mCurrText.setSingleLine();
        mNextText.setSingleLine();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    mScaledTextSpacing = (int) (TEXT_SPACING * density);
}

From source file:com.auth0.android.lock.views.PasswordlessFormLayout.java

private void addSeparator() {
    orSeparatorMessage = new LineSpacingTextView(getContext());
    int passwordlessMode = lockWidget.getConfiguration().getPasswordlessMode();
    int stringRes = R.string.com_auth0_lock_passwordless_email_forms_separator;
    if (passwordlessMode == PasswordlessMode.SMS_LINK || passwordlessMode == PasswordlessMode.SMS_CODE) {
        stringRes = R.string.com_auth0_lock_passwordless_sms_forms_separator;
    }/*w w  w. j  a va 2s .  c o  m*/
    orSeparatorMessage.setText(stringRes);
    orSeparatorMessage
            .setLineSpacing(getResources().getDimension(R.dimen.com_auth0_lock_separator_text_spacing), 1);
    orSeparatorMessage.setTextColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_text));
    orSeparatorMessage.setTextSize(TypedValue.COMPLEX_UNIT_PX,
            getResources().getDimension(R.dimen.com_auth0_lock_title_text));
    orSeparatorMessage.setGravity(Gravity.CENTER);
    int verticalPadding = getResources()
            .getDimensionPixelSize(R.dimen.com_auth0_lock_widget_vertical_margin_field);
    LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(0, verticalPadding, 0, verticalPadding);
    addView(orSeparatorMessage, params);
}

From source file:com.muzhi.camerasdk.view.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);//from ww  w.  j a  v  a 2 s  .c  o  m
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    a = context.obtainStyledAttributes(attrs, R.styleable.CameraSDKPagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsIndicatorColor,
            indicatorColor);
    underlineColor = a.getColor(R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsUnderlineColor,
            underlineColor);
    dividerColor = a.getColor(R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsDividerColor,
            dividerColor);
    indicatorHeight = a.getDimensionPixelSize(
            R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsIndicatorHeight, indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(
            R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsUnderlineHeight, underlineHeight);
    dividerPadding = a.getDimensionPixelSize(
            R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsDividerPadding, dividerPadding);
    tabPadding = a.getDimensionPixelSize(
            R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsShouldExpand,
            shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsScrollOffset,
            scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.CameraSDKPagerSlidingTabStrip_camerasdk_pstsTextAllCaps,
            textAllCaps);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.arlib.floatingsearchview.suggestions.SearchSuggestionsAdapter.java

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {

    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.search_suggestion_item, viewGroup,
            false);/*from  ww w  .ja  va 2 s  . c o m*/
    SearchSuggestionViewHolder viewHolder = new SearchSuggestionViewHolder(view,
            new SearchSuggestionViewHolder.Listener() {

                @Override
                public void onItemClicked(int adapterPosition) {

                    if (mListener != null)
                        mListener.onItemSelected(mSearchSuggestions.get(adapterPosition));
                }

                @Override
                public void onMoveItemToSearchClicked(int adapterPosition) {

                    if (mListener != null)
                        mListener.onMoveItemToSearchClicked(mSearchSuggestions.get(adapterPosition));
                }

            });

    viewHolder.rightIcon.setImageDrawable(mRightIconDrawable);
    viewHolder.body.setTextSize(TypedValue.COMPLEX_UNIT_PX, mBodyTextSizePx);

    return viewHolder;
}

From source file:com.annanovas.bestprice.Fragment.DashBoardFragment.java

private void updateDashboard() {
    int imageDimen = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
            getResources().getDimension(R.dimen.size_150dp), getResources().getDisplayMetrics());

    myDB.open();//  w ww . ja va 2  s. co m
    Cursor cursor = myDB.getUserInfo(userType, sharedPreferences.getString("user_phone_number", ""));

    if (userType == AppGlobal.CAR_OWNER) {
        carLayout.setVisibility(View.VISIBLE);
        quotationLayout.setVisibility(View.VISIBLE);
        searchProductLayout.setVisibility(View.VISIBLE);
        if (myDB.getUserCount() > 1) {
            buttonUserType.setVisibility(View.VISIBLE);
        }

        if (!cursor.isLast()) {
            while (cursor.moveToNext()) {
                String name = "";
                if (cursor.getString(cursor.getColumnIndex("firstname")) != null
                        && !cursor.getString(cursor.getColumnIndex("firstname")).equals("null")) {
                    name = cursor.getString(cursor.getColumnIndex("firstname")) + " ";
                }
                if (cursor.getString(cursor.getColumnIndex("middlename")) != null
                        && !cursor.getString(cursor.getColumnIndex("middlename")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("middlename")) + " ";
                }
                if (cursor.getString(cursor.getColumnIndex("lastname")) != null
                        && !cursor.getString(cursor.getColumnIndex("lastname")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("lastname"));
                }
                tvName.setText(name.trim());
                tvPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone")));
                tvEmail.setText(cursor.getString(cursor.getColumnIndex("email")));

                if (cursor.getString(cursor.getColumnIndex("image")) != null
                        && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) {
                    //showLog("Image Path: " + AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image")));
                    Glide.with(getActivity())
                            .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image")))
                            .error(R.drawable.ic_car_owner).dontAnimate().override(imageDimen, imageDimen)
                            .into(userImage);
                } else {
                    userImage.setImageResource(R.drawable.ic_car_owner);
                }

                sharedPreferences.edit()
                        .putString("api_token", cursor.getString(cursor.getColumnIndex("api_token"))).apply();
                sharedPreferences.edit().putInt("user_id", cursor.getInt(cursor.getColumnIndex("id"))).apply();
            }
        }
        cursor.close();
        tvUserType.setText(getResources().getString(R.string.user_type1));

    } else if (userType == AppGlobal.SUPPLIER) {
        tvAddress.setVisibility(View.VISIBLE);
        tvDealership.setVisibility(View.VISIBLE);
        quotationLayout.setVisibility(View.VISIBLE);
        if (myDB.getUserCount() > 1) {
            buttonUserType.setVisibility(View.VISIBLE);
        }

        if (!cursor.isLast()) {
            while (cursor.moveToNext()) {
                String name = "";
                if (cursor.getString(cursor.getColumnIndex("firstname")) != null
                        && !cursor.getString(cursor.getColumnIndex("firstname")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("firstname")) + " ";
                }
                if (cursor.getString(cursor.getColumnIndex("middlename")) != null
                        && !cursor.getString(cursor.getColumnIndex("middlename")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("middlename")) + " ";
                }
                if (cursor.getString(cursor.getColumnIndex("lastname")) != null
                        && !cursor.getString(cursor.getColumnIndex("lastname")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("lastname"));
                }
                tvName.setText(name.trim());
                tvAddress.setText(cursor.getString(cursor.getColumnIndex("address")));
                tvPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone")));
                tvEmail.setText(cursor.getString(cursor.getColumnIndex("email")));
                tvDealership.setText("Dealership With: "
                        + myDB.getBrandsNameFromUserId(cursor.getInt(cursor.getColumnIndex("id"))));

                if (cursor.getString(cursor.getColumnIndex("image")) != null
                        && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) {
                    Glide.with(getActivity())
                            .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image")))
                            .error(R.drawable.ic_supplier).dontAnimate().override(imageDimen, imageDimen)
                            .into(userImage);
                } else {
                    userImage.setImageResource(R.drawable.ic_supplier);
                }

                sharedPreferences.edit()
                        .putString("api_token", cursor.getString(cursor.getColumnIndex("api_token"))).apply();
                sharedPreferences.edit().putInt("user_id", cursor.getInt(cursor.getColumnIndex("id"))).apply();
            }
        }
        cursor.close();
        tvUserType.setText(getResources().getString(R.string.user_type2));

    } else if (userType == AppGlobal.DRIVER) {
        tvDrivingLicense.setVisibility(View.VISIBLE);
        tvNid.setVisibility(View.VISIBLE);
        tvExperience.setVisibility(View.VISIBLE);
        pendingTaskLayout.setVisibility(View.VISIBLE);

        if (!cursor.isLast()) {
            while (cursor.moveToNext()) {
                String name = "";
                if (cursor.getString(cursor.getColumnIndex("firstname")) != null
                        && !cursor.getString(cursor.getColumnIndex("firstname")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("firstname")) + " ";
                }
                if (cursor.getString(cursor.getColumnIndex("middlename")) != null
                        && !cursor.getString(cursor.getColumnIndex("middlename")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("middlename")) + " ";
                }
                if (cursor.getString(cursor.getColumnIndex("lastname")) != null
                        && !cursor.getString(cursor.getColumnIndex("lastname")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("lastname"));
                }
                tvName.setText(name.trim());
                tvPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone")));
                tvEmail.setText(cursor.getString(cursor.getColumnIndex("email")));
                tvDrivingLicense.setText(
                        "Driving License no.: " + cursor.getString(cursor.getColumnIndex("drivinglicence")));
                tvNid.setText("NID no.: " + cursor.getString(cursor.getColumnIndex("nid")));
                tvExperience.setText(
                        "Years of Experience: " + cursor.getString(cursor.getColumnIndex("yearofexperience")));

                if (cursor.getString(cursor.getColumnIndex("image")) != null
                        && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) {
                    Glide.with(getActivity())
                            .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image")))
                            .error(R.drawable.ic_driver).dontAnimate().override(imageDimen, imageDimen)
                            .into(userImage);
                } else {
                    userImage.setImageResource(R.drawable.ic_driver);
                }

                sharedPreferences.edit()
                        .putString("api_token", cursor.getString(cursor.getColumnIndex("api_token"))).apply();
                sharedPreferences.edit().putInt("user_id", cursor.getInt(cursor.getColumnIndex("id"))).apply();
            }
        }
        cursor.close();
        tvUserType.setText(getResources().getString(R.string.user_type3));

    } else if (userType == AppGlobal.SHOP_WORKER) {
        tvShopName.setVisibility(View.VISIBLE);
        tvNid.setVisibility(View.VISIBLE);
        pendingTaskLayout.setVisibility(View.VISIBLE);

        if (!cursor.isLast()) {
            while (cursor.moveToNext()) {
                String name = "";
                if (cursor.getString(cursor.getColumnIndex("firstname")) != null
                        && !cursor.getString(cursor.getColumnIndex("firstname")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("firstname")) + " ";
                }
                if (cursor.getString(cursor.getColumnIndex("middlename")) != null
                        && !cursor.getString(cursor.getColumnIndex("middlename")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("middlename")) + " ";
                }
                if (cursor.getString(cursor.getColumnIndex("lastname")) != null
                        && !cursor.getString(cursor.getColumnIndex("lastname")).equals("null")) {
                    name = name + cursor.getString(cursor.getColumnIndex("lastname"));
                }
                tvName.setText(name.trim());
                tvPhoneNumber.setText(cursor.getString(cursor.getColumnIndex("phone")));
                tvEmail.setText(cursor.getString(cursor.getColumnIndex("email")));
                tvShopName.setText("Shop Name: " + cursor.getString(cursor.getColumnIndex("shopname")));
                tvNid.setText("NID no.: " + cursor.getString(cursor.getColumnIndex("nid")));

                if (cursor.getString(cursor.getColumnIndex("image")) != null
                        && !cursor.getString(cursor.getColumnIndex("image")).equals("null")) {
                    Glide.with(getActivity())
                            .load(AppGlobal.userImagePath + cursor.getString(cursor.getColumnIndex("image")))
                            .error(R.drawable.ic_shop_worker).dontAnimate().override(imageDimen, imageDimen)
                            .into(userImage);
                } else {
                    userImage.setImageResource(R.drawable.ic_shop_worker);
                }

                sharedPreferences.edit()
                        .putString("api_token", cursor.getString(cursor.getColumnIndex("api_token"))).apply();
                sharedPreferences.edit().putInt("user_id", cursor.getInt(cursor.getColumnIndex("id"))).apply();
            }
        }
        cursor.close();
        tvUserType.setText(getResources().getString(R.string.user_type4));
    }
    myDB.close();
}

From source file:com.muzhi.widget.views.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);//w w w. j  a  va  2s. c o m
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:cat.ereza.customactivityoncrash.activity.DefaultErrorReportActivity.java

@SuppressLint("PrivateResource")
@Override/*from w  ww.ja  va 2 s  .c  o m*/
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //This is needed to avoid a crash if the developer has not specified
    //an app-level theme that extends Theme.AppCompat
    TypedArray a = obtainStyledAttributes(R.styleable.AppCompatTheme);
    if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar)) {
        setTheme(R.style.Theme_AppCompat_Light_DarkActionBar);
    }
    a.recycle();

    setContentView(R.layout.customactivityoncrash_default_error_activity);

    //Close/restart button logic:
    //If a class if set, use restart.
    //Else, use close and just finish the app.
    //It is recommended that you follow this logic if implementing a custom error activity.
    Button restartButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_restart_button);

    final CaocConfig config = CustomActivityOnCrash.getConfigFromIntent(getIntent());

    if (config.isShowRestartButton() && config.getRestartActivityClass() != null) {
        restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app);
        restartButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CustomActivityOnCrash.restartApplication(DefaultErrorReportActivity.this, config);
            }
        });
    } else {
        restartButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CustomActivityOnCrash.closeApplication(DefaultErrorReportActivity.this, config);
            }
        });
    }

    Button moreInfoButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_more_info_button);

    if (config.isShowErrorDetails()) {
        moreInfoButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //We retrieve all the error data and show it

                AlertDialog dialog = new AlertDialog.Builder(DefaultErrorReportActivity.this)
                        .setTitle(R.string.customactivityoncrash_error_activity_error_details_title)
                        .setMessage(CustomActivityOnCrash
                                .getAllErrorDetailsFromIntent(DefaultErrorReportActivity.this, getIntent()))
                        .setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close,
                                null)
                        .setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy,
                                new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        copyErrorToClipboard();
                                        Toast.makeText(DefaultErrorReportActivity.this,
                                                R.string.customactivityoncrash_error_activity_error_details_copied,
                                                Toast.LENGTH_SHORT).show();
                                    }
                                })
                        .show();
                TextView textView = (TextView) dialog.findViewById(android.R.id.message);
                textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources()
                        .getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size));
            }
        });
    } else {
        moreInfoButton.setVisibility(View.GONE);
    }

    Integer defaultErrorActivityDrawableId = config.getErrorDrawable();
    ImageView errorImageView = ((ImageView) findViewById(R.id.customactivityoncrash_error_activity_image));

    if (defaultErrorActivityDrawableId != null) {
        errorImageView.setImageDrawable(
                ResourcesCompat.getDrawable(getResources(), defaultErrorActivityDrawableId, getTheme()));
    }
}

From source file:cn.wander.Utils.views.pageindicator.TabPageIndicator.java

private void addTab(int index, CharSequence text, int iconResId) {
    RelativeLayout tablayout = (RelativeLayout) View.inflate(getContext(), R.layout.tab_item_layout, null);

    final TextView tabView = (TextView) tablayout.findViewById(R.id.tab_item_title);
    tabView.setTag(index);/*from   ww  w . jav a2  s  .co m*/
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 19);
    tabView.setText(text);
    tabView.setTextColor(getResources().getColor(R.color.kw_common_cl_white));
    if (iconResId != 0) {
        //             tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
        ImageView iconView = (ImageView) tablayout.findViewById(R.id.tab_item_icon);
        iconView.setImageResource(iconResId);
        iconView.setVisibility(View.VISIBLE);
    }

    mTabLayout.addView(tablayout, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
}

From source file:com.asc_ii.bangnote.bigbang.BigBangLayout.java

public void setItemTextSize(int sp) {
    mItemTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp,
            getResources().getDisplayMetrics());
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        if (child instanceof TextView) {
            ((TextView) child).setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemTextSize);
        }/*from w ww  . j  a  v  a2  s . c o m*/
    }
}