How to move text in the textview?

I want to move text in the textview a little bit higher. How I can do that? My textview:

    <TextView android:layout_width="45dp" 
       android:layout_height="45dp" 
     **android:id="@+id/tv_number"** 
       android:layout_gravity="center_vertical" 
       android:background="@drawable/oval" 
       android:textIsSelectable="false" 
       android:textStyle="normal|bold" 
       android:textSize="40sp" 
       android:layout_marginLeft="10dp" 
       android:text="1" 
       android:textColor="#ffffff" 
       tools:targetApi="jelly_bean_mr1" 
       android:textAlignment="inherit" />

Upvotes: 1

Views: 6256

Answers (2)

Timo
Timo

Reputation: 308

You can set the padding bottom or top. If you set the padding bottom, your Text is placed higher and if you set a padding top your Text will be placed lower. Try: android:paddingBottom="5dp"

Upvotes: 3

Neh
Neh

Reputation: 452

For the text inside Textview, you need to set "android:gravity" which makes the content of Your TextView aligned . You have used "android:layout_gravity" which makes alignment of TextView respected to its Parent Layout.

So as to change the vertical alignment of text inside textview, for example you can use, android:gravity="center|right"

If you want to exactly center your text, this might be helpful How do I center text horizontally and vertically in a TextView on Android?

Upvotes: 0

Related Questions