---
title: "How do I center text horizontally and vertically in a TextView in Android?"  
description: "How do I center text horizontally and vertically in a TextView in Android?"  
author: "Anonymous User"  
published: 2015-05-19  
updated: 2015-05-19  
canonical: https://www.mindstick.com/forum/23237/how-do-i-center-text-horizontally-and-vertically-in-a-textview-in-android  
category: "android"  
tags: ["android"]  
reading_time: 1 minute  

---

# How do I center text horizontally and vertically in a TextView in Android?

How do I center the [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) [horizontally and vertically](https://www.mindstick.com/forum/158678/how-can-center-align-an-element-both-horizontally-and-vertically-using-css) in a TextView in [Android](https://www.mindstick.com/articles/13046/10-reasons-why-i-prefer-android-vs-iphone-ios), so that it appears exactly in the middle of the TextView

## Replies

### Reply by Anonymous User

Use:

```
android:gravity="center" 
```

in your TextView tags xmlThe textview has to be match_parent or fill_parent for this to work. If its wrap content, then it will not center.\


---

Original Source: https://www.mindstick.com/forum/23237/how-do-i-center-text-horizontally-and-vertically-in-a-textview-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
