As shown in the pic below, I want the text of each button to be centered, not in the sense of that, the text should be started to be written from the center but in the sense of, the center of the text should be also the center of the view.
i used in the xml file, the gravity property and layout_centerInParent="true" as well, but as you see below, the text started to be written from the center of the view.
please let me know which property can do this job?
XML
<RelativeLayout
xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/et_IP"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="IP Address" />
<EditText
android:layout_below="@+id/et_IP"
android:id="@+id/et_port"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="1883" />
<Button
android:layout_below="@+id/et_port"
android:id="@+id/bt_connect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Connect..."/>
<Button
android:layout_below="@+id/bt_connect"
android:id="@+id/bt_clear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Clear"/>
<TextView
android:layout_below="@+id/bt_clear"
android:gravity="center"
android:id="@+id/tv_response"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="NO_RESPONSE"/>
</RelativeLayout>
Pic
No comments:
Post a Comment