Unable to center the text in textview

user3293494

I am using following code to center the text in textview.

<TextView android:layout_height="20dp" 
android:layout_width="20dp" 
android:text="?"
android:id="@+id/tv281"
android:textSize="18sp"
android:background="@drawable/qcircle"
android:gravity="center"
android:layout_marginRight="5dp"
></TextView>

But the "?" is not vertically centered. What is wrong ?

xgc1986

The text is already centered vertically, but the layout height is too small, or textSize too big, change that

edit

this is better

android:includeFontPadding="false"

the problem is that the text font is too big for the layout height, then you can change this values, but also the problem is the padding of the layout, if you put android:padding="0dp" won't work, because the padding of the font, the best solution is not to include de font's padding in the TextView

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Unable to center the text in TextView when width is set to 'match_parent'

From Dev

Unable to center text on image

From Dev

Unable to Center Edit Text in Android

From Dev

Unable to Center Text using CSS

From Dev

CSS Unable to center text in Div

From Dev

Can´t center textview´s text vertically

From Dev

How to center text on TextView's background

From Dev

Horizontally and Vertically center text for TextView in Android

From Dev

How to center the text and icon simultaneously in the TextView?

From Dev

Center text in textview is changing the view size based on text length

From Dev

TextView Alignment in LinearLayout android. Unable to place it at Center of Layout

From Dev

TextView Alignment in LinearLayout android. Unable to place it at Center of Layout

From Dev

Android: unable to change color of part of the text in textview

From Dev

Unable to center text inside an absolute positioned div

From Dev

Unable to display center text in ring chart

From Dev

Unable to center logo and text displayed side by side

From Java

How do I center text horizontally and vertically in a TextView?

From Dev

Need to center-align a single portion of text in a TextView

From Dev

Align text to the right and center vertically, xamarin android textview

From Dev

Unable to set text in the TextView of custom dialog entered through EditText of an activity

From Dev

PyQt5 Unable to Center Align Text in Qlabel

From Dev

Android textview center positioning

From Dev

Center a button and textView

From Dev

Android textview center letter

From Dev

TextView will not center its content

From Dev

Android - Center Textview in LinearLayout

From Dev

Center a TextView in a TableRow in a TableLayout

From Dev

Align TextView to center of RelativeLayout

From Dev

Center a TextView in a TableRow in a TableLayout

Related Related

  1. 1

    Unable to center the text in TextView when width is set to 'match_parent'

  2. 2

    Unable to center text on image

  3. 3

    Unable to Center Edit Text in Android

  4. 4

    Unable to Center Text using CSS

  5. 5

    CSS Unable to center text in Div

  6. 6

    Can´t center textview´s text vertically

  7. 7

    How to center text on TextView's background

  8. 8

    Horizontally and Vertically center text for TextView in Android

  9. 9

    How to center the text and icon simultaneously in the TextView?

  10. 10

    Center text in textview is changing the view size based on text length

  11. 11

    TextView Alignment in LinearLayout android. Unable to place it at Center of Layout

  12. 12

    TextView Alignment in LinearLayout android. Unable to place it at Center of Layout

  13. 13

    Android: unable to change color of part of the text in textview

  14. 14

    Unable to center text inside an absolute positioned div

  15. 15

    Unable to display center text in ring chart

  16. 16

    Unable to center logo and text displayed side by side

  17. 17

    How do I center text horizontally and vertically in a TextView?

  18. 18

    Need to center-align a single portion of text in a TextView

  19. 19

    Align text to the right and center vertically, xamarin android textview

  20. 20

    Unable to set text in the TextView of custom dialog entered through EditText of an activity

  21. 21

    PyQt5 Unable to Center Align Text in Qlabel

  22. 22

    Android textview center positioning

  23. 23

    Center a button and textView

  24. 24

    Android textview center letter

  25. 25

    TextView will not center its content

  26. 26

    Android - Center Textview in LinearLayout

  27. 27

    Center a TextView in a TableRow in a TableLayout

  28. 28

    Align TextView to center of RelativeLayout

  29. 29

    Center a TextView in a TableRow in a TableLayout

HotTag

Archive