I want the controller textView to be centre of the app. I used android:gravity="center" but doesn't help. My code is
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CONTROLLER"
android:textSize="30dp"
android:gravity="center"
android:textColor="#fff"
android:layout_marginTop="39dp"
android:id="@+id/textView3"
/>
</LinearLayout>
Thanks in advance for helping.
Just android:gravity="center"
in the Layout and also android:layout_height="match_parent"
to the center the TextView in the whole View. and android:gravity="center_horizontal" to centralize it horizontaly.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CONTROLLER"
android:textSize="30sp"
android:textColor="#fff"
android:layout_marginTop="39dp"
android:id="@+id/textView3"
/>
</LinearLayout>
and also the textSize should be meausured in sp not dp.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.