Xamarin.Android 水平對齊與垂直對齊


水平對齊:

1、LinearLayout添加屬性:android:orientation="vertical";

2、元件添加屬性:android:layout_gravity="center_horizontal"。

<LinearLayout
   android:layout_width="match_parent"
   android:layout_height="200dp"
   android:orientation="vertical">
  <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="我要居中對齊呀~"/>
</LinearLayout>
 

垂直對齊:

1、LinearLayout添加屬性:android:orientation="horizontal";

2、元件添加屬性:android:layout_gravity="center_vertical"。

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="horizontal" > 
  <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="我要垂直對齊呀~" />
</LinearLayout>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM