TextView getTextSize - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TextView getTextSize method.

This code example shows how to use the following methods:getTextSize, getTypeface
     * @param numberOfDigits 
     * @return number width 
     */ 
    public static int getWidth(TextView view, int numberOfDigits) {
        Paint paint = new Paint();
        paint.setTypeface(view.getTypeface());
        paint.setTextSize(view.getTextSize());
        char[] text = new char[numberOfDigits];
        Arrays.fill(text, '0');
        return Math.round(paint.measureText(text, 0, text.length));
    } 
 
    /** 
     * Get octicons typeface 
     * 
     * @param context 
     * @return octicons typeface 
     */ 
    public static Typeface getOcticons(final Context context) {
        if (OCTICONS == null)
7
CodeRank
This code example shows how to use the following methods:getText, getTextColors, getTextSize
 
            new NotificationViewSearcher(n, context, new Predicate<View>() {
                public boolean apply(View view) {
                    if (view instanceof TextView) {
                        TextView tv = (TextView) view;
                        if (tv.getText().toString().startsWith(TEXT_SEARCH_PREFIX)) {
                            int textColour = tv.getTextColors().getDefaultColor();
                            TextAppearance appearance = new TextAppearance(textColour, tv.getTextSize()/displayMetrics.scaledDensity);
 
                            if (TEXT_SEARCH_TEXT.equals(tv.getText().toString())) {
                                textAppearance = appearance;
                            } else { 
                                titleAppearance = appearance;
                            } 
                            return !needToSearch(); 
                        } 
                    } 
                    return false; 
                } 
            }).search(); 
8
CodeRank
This code example shows how to use the following methods:getTextSize, setTextSize
     * The font sizes in the layout files are specified for a HVGA display. 
     * Adjust the font sizes accordingly if we are running on a different 
     * display. 
     */ 
    public void adjustFontSize(TextView view) {
        float fontPixelSize = view.getTextSize();
        Display display = getWindowManager().getDefaultDisplay();
        int h = Math.min(display.getWidth(), display.getHeight());
        float ratio = (float)h/HVGA_WIDTH_PIXELS;
        view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontPixelSize*ratio);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getTextSize, setTextSize
        return super.onMenuItemSelected(featureId, item);
    } 
 
    private void changeTextSize(float factor)
    { 
        mTextSize = mBodyText.getTextSize();
        mTextSize *= factor;
 
        mBodyText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
 
        getSharedPreferences(PREFS_NAME, MODE_PRIVATE)
            .edit()
            .putFloat(TEXT_SIZE, mTextSize)
            .commit();
 
    } 
 
    private void setupView(boolean hasImage)
    { 
 
6
CodeRank
This code example shows how to use the following methods:getTextSize, setTextSize
     * The font sizes in the layout files are specified for a HVGA display. 
     * Adjust the font sizes accordingly if we are running on a different 
     * display. 
     */ 
    public void adjustFontSize(TextView view) {
        float fontPixelSize = view.getTextSize();
        Display display = getWindowManager().getDefaultDisplay();
        int h = Math.min(display.getWidth(), display.getHeight());
        float ratio = 0; 
        if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){
            ratio = (float)h/HVGA_WIDTH_PIXELS;
        }else{ 
            ratio = (float)h/HVGA_HEIGHT_PIXELS;
        } 
        view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontPixelSize*ratio);
    } 
 
    @Override 
    public void onClick(View v) {
        if (v.getId() == R.id.cal2_ok) {
5
CodeRank
This code example shows how to use the following methods:getTextSize, setHint
        String hintText = getResources().getString(hintTextId);
        Drawable searchIcon = getResources().getDrawable(imageDrawableId);
 
        SpannableStringBuilder ssb = new SpannableStringBuilder("   "); // for the icon
        ssb.append(hintText);
        int textSize = (int) (mAutoCompleteTextView.getTextSize() * 1.25);
        searchIcon.setBounds(0, 0, textSize, textSize);
        ssb.setSpan(new ImageSpan(searchIcon), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        mAutoCompleteTextView.setHint(ssb);
    } 
 
    // Implementation of TextWatcher 
    @Override 
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    } 
 
    // Implementation of TextWatcher 
    @Override 
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if (mFirstTime && mHideFilterSearchOnStart) {
4
CodeRank

Related TextView getTextSize Questions & Answers:

getTextSize Method Overview
See Code Examples for other Android TextView Methods: