RealTextView icon indicating copy to clipboard operation
RealTextView copied to clipboard

RealEditText doesn't work when being added programmatically

Open AndroidDeveloperLB opened this issue 9 years ago • 0 comments

instead of using XML, try to add the view programmatically. The text won't auto-fit. Instead, it will have quite a small font.

Here's a small snippet to show the issue:

    ViewGroup viewGroup = (ViewGroup) findViewById(R.id.container);
    RealEditText editText = new RealEditText(this);
    editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 70);
    editText.setTextColor(0xffff2222);
    editText.setMaxLines(2);
    editText.setMinTextSize(TypedValue.COMPLEX_UNIT_DIP, 8);
    editText.setFocusableInTouchMode(true);
    editText.setFocusable(true);
    editText.setText("Some text");
    editText.setGravity(Gravity.LEFT | Gravity.START | Gravity.CENTER_VERTICAL);
    ViewGroup.LayoutParams layoutParams = new LayoutParams(400, 200);
    editText.setLayoutParams(layoutParams);
    viewGroup.addView(editText);

AndroidDeveloperLB avatar Jun 15 '15 10:06 AndroidDeveloperLB