I have just started learning Android and thought of a simple project to help me learn.
I have created a simple menu using a ListView on a LinearLayout.
What I want to do is center the text in the ListView and also center the ListView in the layout.
I tried setting gravity to center-Hozitonal but that didn’t work.
You can set the
gravity(notlayout_gravity) attribute to center text. Make sure that you also setlayout_widthis set to"fill_parent". For example, inmy_text_view.xml:And then you can use
R.id.my_text_viewas your resource id.