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

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>

 

posted @ 2019-04-22 11:41 鍵盤演繹青春 閱讀(...) 評論(...) 編輯 收藏
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章