Let us see two ways to add padding to Android TextView,
1. Using XML Attribute
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello World"
android:padding="10dp"/>
You may also want to use the below padding options based on your use case.
- paddingLeft
- paddingRight
- paddingTop
- paddingBottom
- paddingStart
- paddingEnd
- paddingVertical
- paddingHorizontal
2. Setting TextView Padding Programatically
TextView tv = findViewById(R.id.myTextView);
tv.setPadding(50,10,10,10);
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!

Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!