I try to add a textview to a relative layout at position 0,0 !
Following code is used:
TextView text = new TextView(getActivity());
text.setTextColor(Color.RED);
text.setIncludeFontPadding(false);
text.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
text.setTextSize(TypedValue.COMPLEX_UNIT_PX, 32 * getResources().getDisplayMetrics().density);
text.setText("TEST TEXT");
text.setSingleLine(false);
text.setX(0);
text.setY(0);
text.setTypeface(fct.getFont().getTypeFace(getActivity())); container.addView(text);
container is a relative layout defined here:
<RelativeLayout
android:id="@+frontcard/container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
I use a custom font with the textview...
The problem is that the text view is not displayed correctly. There is a padding to the top ... left is set correct.
Image for the output:
If i draw it on a canvas everything works fine like this image shows:
Do i have a problem with the custom font in a textview ?
Anyone has any ideas ?