andriod 文本置中: android:gravity="center"

來源:互聯網
上載者:User

標籤:visible   near   put   tty   col   nta   sum   ica   appear   

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"    android:orientation="vertical"    android:weightSum="1">    <LinearLayout        android:orientation="horizontal"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginTop="10dp"        android:layout_marginBottom="10dp">        <TextView            android:layout_width="0dp"            android:layout_height="wrap_content"            android:textAppearance="?android:attr/textAppearanceLarge"            android:text="姓:"            android:id="@+id/textView"            android:layout_weight="1" />        <EditText            android:layout_width="0dp"            android:layout_height="wrap_content"            android:id="@+id/surName"            android:layout_weight="4"            android:hint="請輸入姓氏"            android:singleLine="true" />    </LinearLayout>    <LinearLayout        android:orientation="horizontal"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginTop="10dp"        android:layout_marginBottom="10dp">        <TextView            android:layout_width="0dp"            android:layout_height="wrap_content"            android:textAppearance="?android:attr/textAppearanceLarge"            android:text="名:"            android:id="@+id/textView2"            android:layout_weight="1" />        <EditText            android:layout_width="0dp"            android:layout_height="wrap_content"            android:id="@+id/firstName"            android:layout_weight="4"            android:singleLine="true"            android:hint="請輸入名字" />    </LinearLayout>    <LinearLayout        android:orientation="horizontal"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_marginTop="10dp"        android:layout_marginBottom="10dp">        <TextView            android:layout_width="0dp"            android:layout_height="wrap_content"            android:textAppearance="?android:attr/textAppearanceLarge"            android:text="電話:"            android:id="@+id/textView3"            android:layout_weight="1" />        <EditText            android:layout_width="0dp"            android:layout_height="wrap_content"            android:inputType="phone"            android:ems="10"            android:id="@+id/phone"            android:layout_weight="4"            android:hint="(02)23963257" />    </LinearLayout>    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="確定"        android:id="@+id/button"        android:onClick="onclick"        android:layout_margin="20dp" />    <TextView        android:id="@+id/txv"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="我愛你"        android:gravity="center"        android:textSize="30sp"        android:visibility="visible" /></LinearLayout>

文本置中:  android:gravity="center"

 

也可以在這樣

LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"    android:orientation="vertical"    android:gravity="center">    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="變變變..."        android:id="@+id/button"        android:textSize="45sp"        android:onClick="changeColor" />    <TextView android:text="紅:?" android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/txvR"        android:textSize="45sp" />    <TextView        android:text="綠:?"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/txvG"        android:textSize="45sp" />    <TextView        android:text="藍:?"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:id="@+id/txvB"        android:textSize="45sp" />    <LinearLayout        android:orientation="horizontal"        android:layout_width="match_parent"        android:layout_height="0dp"        android:id="@+id/colorBlock"        android:layout_weight="1"></LinearLayout></LinearLayout>

 

andriod 文本置中: android:gravity="center"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.