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.github.kubatatami.InternalSteppersAdapter.java

@Override
public void onBindViewHolder(final SteppersViewHolder holder, final int position) {
    int externalAdapterPosition = getExternalAdapterPosition(position);
    holder.setChecked(position < currentStep);
    if (holder.isChecked()) {
        holder.roundedView.setChecked(true);
    } else {/* w ww .  j ava2s  . c  om*/
        holder.roundedView.setChecked(false);
        holder.roundedView.setText(Integer.toString(position + 1));
    }
    if (position == currentStep) {
        holder.roundedView.setCircleColor(steppersView.getCircleActiveColor());
        holder.textViewLabel.setTextColor(steppersView.getLabelActiveTextColor());
        holder.textViewSubLabel.setTextColor(steppersView.getSubLabelActiveTextColor());
    } else if (holder.isChecked()) {
        holder.roundedView.setCircleColor(steppersView.getCircleDoneColor());
        holder.textViewLabel.setTextColor(steppersView.getLabelDoneTextColor());
        holder.textViewSubLabel.setTextColor(steppersView.getSubLabelDoneTextColor());
    } else {
        holder.roundedView.setCircleColor(steppersView.getCircleInactiveColor());
        holder.textViewLabel.setTextColor(steppersView.getLabelInactiveTextColor());
        holder.textViewSubLabel.setTextColor(steppersView.getSubLabelInactiveTextColor());
    }
    if (position < currentStep && steppersView.isBackByTap()) {
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setStep(position);
            }
        });
    } else {
        holder.itemView.setOnClickListener(null);
    }

    holder.textViewLabel.setText(adapter.getLabel(externalAdapterPosition));
    holder.textViewSubLabel.setText(adapter.getSubLabel(externalAdapterPosition));
    holder.textViewLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, steppersView.getLabelTextSize());
    holder.textViewSubLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, steppersView.getSubLabelTextSize());

    holder.frameLayout.setVisibility(position == currentStep ? View.VISIBLE : View.GONE);
}

From source file:com.waz.zclient.ui.calling.CallControlButtonView.java

private void init(AttributeSet attrs) {
    setOrientation(VERTICAL);/*from w  ww.  j av  a  2s . c  o  m*/
    setGravity(Gravity.CENTER);
    setBackgroundColor(ContextCompat.getColor(getContext(), R.color.transparent));

    int circleIconDimension = 0;
    String circleIconGlyph = "";
    int circleIconStyle = 0;
    String labelText = "";
    int buttonLabelWidth = 0;
    int labelTextSize = 0;
    String labelFont = "";

    if (attrs != null) {
        TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.CallControlButtonView,
                0, 0);
        circleIconDimension = a.getDimensionPixelSize(R.styleable.CallControlButtonView_circleIconDimension, 0);
        circleIconGlyph = a.getString(R.styleable.CallControlButtonView_circleIconGlyph);
        circleIconStyle = attrs.getStyleAttribute();
        labelText = a.getString(R.styleable.CallControlButtonView_labelText);
        buttonLabelWidth = a.getDimensionPixelSize(R.styleable.CallControlButtonView_labelWidth, 0);
        labelTextSize = a.getDimensionPixelSize(R.styleable.CallControlButtonView_labelTextSize, 0);
        labelFont = a.getString(R.styleable.CallControlButtonView_labelFont);
        a.recycle();
    }

    buttonView = new GlyphTextView(getContext(), null, circleIconStyle);
    buttonView.setLayoutParams(new LayoutParams(circleIconDimension, circleIconDimension));
    buttonView.setText(circleIconGlyph);
    buttonView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
            getResources().getDimensionPixelSize(R.dimen.wire__icon_button__text_size));
    buttonView.setGravity(Gravity.CENTER);
    if (circleIconStyle == 0) {
        buttonView.setTextColor(new OptionsDarkTheme(getContext()).getTextColorPrimarySelector());
        buttonView.setBackground(
                ContextCompat.getDrawable(getContext(), R.drawable.selector__icon_button__background__calling));
    }
    addView(buttonView);

    buttonLabelView = new TypefaceTextView(getContext(), null, R.attr.callingControlButtonLabel);
    buttonLabelView.setText(labelText);
    buttonLabelView.setTextSize(TypedValue.COMPLEX_UNIT_PX, labelTextSize);
    buttonLabelView.setTypeface(labelFont);
    buttonLabelView.setGravity(Gravity.CENTER);
    if (buttonLabelWidth > 0) {
        addView(buttonLabelView,
                new LinearLayout.LayoutParams(buttonLabelWidth, ViewGroup.LayoutParams.WRAP_CONTENT));
    } else {
        addView(buttonLabelView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
    }
    ViewUtils.setMarginTop(buttonLabelView, getContext().getResources()
            .getDimensionPixelSize(R.dimen.calling__controls__button__label__margin_top));
}

From source file:fi.tuukka.weather.view.FragmentStations.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.asemat, container, false);
    rg = (RadioGroup) view.findViewById(R.id.radioGroup1);
    rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override// w ww. ja  va  2s  . com
        public void onCheckedChanged(RadioGroup rg, int id) {
            if (listenCheck) {
                for (int i = 0; i < rg.getChildCount(); i++) {
                    RadioButton btn = (RadioButton) rg.getChildAt(i);
                    if (btn.getId() == id) {
                        String text = (String) btn.getText();
                        Station station = new Station(text, null);
                        changeStation(station);
                        refreshStations();
                        return;
                    }
                }
            }
        }
    });
    EditText searchBox = (EditText) view.findViewById(R.id.stationSearchBox);
    searchBox.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String string = s.toString();
            if (query == null || !query.equals(string)) {
                query = s.toString();
                stationStrings = null; // mark as not finished
                ((ActivityMain) getActivity()).queryStations();
            }
        }
    });
    Activity activity = getActivity();
    header = (TextView) view.findViewById(R.id.stationsHeader);
    int fontsize = Utils.getScaledFont(activity);
    int pad = Utils.dpToPx(5, activity);
    header.setTextAppearance(activity, R.style.TextStyle);
    header.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontsize);
    header.setPadding(0, pad, 0, pad);
    header.setText("Syt kunta/kunnanosa:");
    super.onCreateView(inflater, container, savedInstanceState);
    return view;
}

From source file:com.scooter1556.sms.android.presenter.MediaItemPresenter.java

@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    MediaBrowserCompat.MediaItem element = (MediaBrowserCompat.MediaItem) item;

    if (element == null) {
        return;/*from  w ww.  j  a v  a  2 s.  c om*/
    }

    ImageCardView cardView = (ImageCardView) viewHolder.view;

    cardView.setMainImageScaleType(ImageView.ScaleType.CENTER);
    cardView.setTitleText(element.getDescription().getTitle());
    cardView.setContentText(element.getDescription().getSubtitle());

    ((TextView) cardView.findViewById(R.id.title_text)).setTextSize(TypedValue.COMPLEX_UNIT_PX,
            cardView.getResources().getDimension(R.dimen.card_image_view_title_text_size));
    ((TextView) cardView.findViewById(R.id.content_text)).setTextSize(TypedValue.COMPLEX_UNIT_PX,
            cardView.getResources().getDimension(R.dimen.card_image_view_content_text_size));

    // Get default icon
    Drawable icon;

    if (element.getMediaId().contains(MediaUtils.MEDIA_ID_AUDIO)) {
        icon = defaultAudioIcon;
    } else if (element.getMediaId().contains(MediaUtils.MEDIA_ID_VIDEO)) {
        icon = defaultMediaIcon;
    } else if (element.getMediaId().contains(MediaUtils.MEDIA_ID_DIRECTORY_AUDIO)) {
        icon = defaultAudioIcon;
    } else if (element.getMediaId().contains(MediaUtils.MEDIA_ID_DIRECTORY_VIDEO)) {
        icon = defaultVideoIcon;
    } else {
        icon = defaultDirectoryIcon;
    }

    List<String> id = MediaUtils.parseMediaId(element.getMediaId());

    if (id.size() > 1) {
        // Set image
        RequestOptions options = new RequestOptions().placeholder(icon).fallback(icon);

        Glide.with(viewHolder.view.getContext()).asBitmap()
                .load(RESTService.getInstance().getConnection().getUrl() + "/image/" + id.get(1)
                        + "/cover?scale=" + CARD_HEIGHT)
                .apply(options).into(cardView.getMainImageView());
    }
}

From source file:com.facebook.react.views.textinput.ReactTextInputShadowNode.java

@Override
public long measure(YogaNode node, float width, YogaMeasureMode widthMode, float height,
        YogaMeasureMode heightMode) {//from  w  w w  . jav a 2s .co  m
    // measure() should never be called before setThemedContext()
    EditText editText = Assertions.assertNotNull(mDummyEditText);

    if (mLocalData != null) {
        mLocalData.apply(editText);
    } else {
        editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextAttributes.getEffectiveFontSize());

        if (mNumberOfLines != UNSET) {
            editText.setLines(mNumberOfLines);
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
                && editText.getBreakStrategy() != mTextBreakStrategy) {
            editText.setBreakStrategy(mTextBreakStrategy);
        }
    }

    // make sure the placeholder content is also being measured
    editText.setHint(getPlaceholder());
    editText.measure(MeasureUtil.getMeasureSpec(width, widthMode),
            MeasureUtil.getMeasureSpec(height, heightMode));

    return YogaMeasureOutput.make(editText.getMeasuredWidth(), editText.getMeasuredHeight());
}

From source file:com.facebook.react.views.textinput.ReactTextInputManager.java

@Override
public ReactEditText createViewInstance(ThemedReactContext context) {
    ReactEditText editText = new ReactEditText(context);
    int inputType = editText.getInputType();
    editText.setInputType(inputType & (~InputType.TYPE_TEXT_FLAG_MULTI_LINE));
    editText.setReturnKeyType("done");
    editText.setTextSize(TypedValue.COMPLEX_UNIT_PX,
            (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)));
    return editText;
}

From source file:com.facebook.LoginButton.java

/**
 * Create the LoginButton by inflating from XML
 * /*from   ww w .jav  a2s  .  c  om*/
 * @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.cqyw.smart.widget.viewpaper.PagerSlidingTabStrip.java

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

    setFillViewport(true);/*from   w  w w .j  ava 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_PX, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, 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);

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

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

    a.recycle();

    // get custom attrs

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

    checkedTextColor = a.getResourceId(R.styleable.TwoTextView_ttLeftTextColor, R.color.theme_color);
    unCheckedTextColor = a.getResourceId(R.styleable.TwoTextView_ttLeftTextColor, R.color.white);
    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);
    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);

    tabViewLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

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

From source file:ecust.news.myWidgetTabPageIndicator.java

public TextView decorateTextView(TextView textView) {
    textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, Global.dimenConvert.dip2px(20));
    textView.setSingleLine();//from ww  w  .j  a v  a2 s.  c o  m
    textView.setTextColor(textViewUnfocusedColor);
    textView.setFocusable(true);
    textView.setClickable(true);

    //Padding
    final int paddingLeftRight = Global.dimenConvert.dip2px(12);
    final int paddingTop = Global.dimenConvert.dip2px(8);
    final int paddingBottom = Global.dimenConvert.dip2px(0);
    textView.setPadding(paddingLeftRight, paddingTop, paddingLeftRight, paddingBottom);

    return textView;
}

From source file:com.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java

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

    setFillViewport(true);//from  w ww .  java2  s  .com
    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_PX, 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);

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

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

    a.recycle();

    // get custom attrs

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

    checkedTextColor = a.getResourceId(R.styleable.TwoTextView_ttLeftTextColor, R.color.color_blue_0888ff);
    unCheckedTextColor = a.getResourceId(R.styleable.TwoTextView_ttLeftTextColor,
            R.color.action_bar_tittle_color_555555);
    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);
    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);

    tabViewLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

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