Example usage for android.widget TextView setIncludeFontPadding

List of usage examples for android.widget TextView setIncludeFontPadding

Introduction

In this page you can find the example usage for android.widget TextView setIncludeFontPadding.

Prototype

public void setIncludeFontPadding(boolean includepad) 

Source Link

Document

Set whether the TextView includes extra top and bottom padding to make room for accents that go above the normal ascent and descent.

Usage

From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.AmharicKeyboardView.java

private void handleModifiers(List<String> typographyList) {
    modifiersContainer.removeAllViews();

    for (int i = 0; i < typographyList.size(); i++) {
        String typography = typographyList.get(i);
        TextView modifierKey = new TextView(getContext());
        modifierKey.setText(typography);
        modifierKey.setTextColor(Color.WHITE);
        modifierKey.setIncludeFontPadding(false);
        modifierKey.setTypeface(mCharTypeface, Typeface.BOLD);
        modifierKey.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        modifierKey.setBackgroundDrawable(
                ContextCompat.getDrawable(getContext(), R.drawable.keyboard_modifierkey_bg));
        modifierKey.setTextSize(18f);/*from  w  w w  .j a va  2 s. c  o m*/
        modifierKey.setGravity(Gravity.CENTER);

        modifierKey.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mEditText == null) {
                    return;
                }
                TextView textView = (TextView) v;
                if (!mEditText.isFocused())
                    mEditText.requestFocus();
                Editable editableText = mEditText.getText();
                int start = mEditText.getSelectionStart();
                if (start == 0)
                    return;

                CharSequence textViewText = textView.getText();
                if (mEnableModifierFlag) {
                    mEnableModifierFlag = false;
                    editableText.replace(start - 1, start, textViewText);
                } else {
                    editableText.insert(start, textViewText);
                }
            }
        });

        LayoutParams params = new LayoutParams(0, LayoutParams.MATCH_PARENT, 1);
        int margin = getCustomSize(1.5f);
        params.setMargins(margin, margin, margin, margin);
        modifiersContainer.addView(modifierKey, params);
    }
}

From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.AmharicKeyboardView.java

private void populateKeyboardRow(KeyboardRow keyboardRow, int keyHeight) {
    Context context = getContext();
    LinearLayout keyContainer = new LinearLayout(context);
    keyContainer.setOrientation(HORIZONTAL);
    keyContainer.setGravity(Gravity.CENTER);

    List<KeyboardKey> keyList = keyboardRow.getKeyList();
    if (keyList != null) {
        for (int i = 0; i < keyList.size(); i++) {
            KeyboardKey keyboardKey = keyList.get(i);
            if (keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_NORMAL) {
                TextView key = new TextView(context);
                key.setGravity(Gravity.CENTER);
                key.setTypeface(mCharTypeface, Typeface.BOLD);
                key.setText(keyboardKey.getCharCode());
                key.setTextSize(16f);//from   w  w  w .  j  a v  a2 s.  c o  m
                key.setTextColor(
                        ContextCompat.getColorStateList(context, R.color.amharic_key_text_color_selector));
                key.setTag(keyboardKey);
                key.setIncludeFontPadding(false);
                keyContainer.setBaselineAligned(false);
                handleChild(key, keyboardKey.getColumnCount(), keyContainer, keyHeight);
            } else if (keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_BACKSPACE
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_SPACE
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_NEW_LINE
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_EVENT_ENTER
                    || keyboardKey.getKeyCommand() == KeyboardKey.KEY_HIDE_KEYBOARD) {
                ImageView child = new ImageView(context);
                child.setImageResource(keyboardKey.getCommandImage());
                int padding = getCustomSize(6);
                child.setPadding(padding, padding, padding, padding);
                child.setTag(keyboardKey);
                handleChild(child, keyboardKey.getColumnCount(), keyContainer, keyHeight);
            }
        }
    }
    addView(keyContainer, new LayoutParams(LayoutParams.MATCH_PARENT, keyHeight));
}