欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android應(yīng)用借助LinearLayout實(shí)現(xiàn)垂直水平居中布局

 更新時(shí)間:2016年04月13日 14:46:05   作者:andie_guo  
這篇文章主要介紹了Android應(yīng)用借助LinearLayout實(shí)現(xiàn)垂直水平居中布局的方法,文中列舉了LinearLayout線性布局下居中相關(guān)的幾個(gè)重要參數(shù),需要的朋友可以參考下

首先說(shuō)的是LinearLayout布局下的居中一般是這樣的:
(注意:android:layout_width="fill_parent" android:layout_height="fill_parent" 屬性中,若水平居中,至少在寬度上占全屏;若垂直居中,則在高度上占全屏)

<LinearLayout 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:gravity="center|center_horizontal|center_vertical" > 
  // 上面gravity屬性的參數(shù):center為居中,center_horizontal為水平居中,center_vertical為垂直居中 
  <Button  
    android:id="@+id/Binding_button"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:text="關(guān)聯(lián)新賬戶" /> 
</LinearLayout>  

要實(shí)現(xiàn)垂直水平居中,幾個(gè)基本參數(shù)值得注意:
1、android:orientation="vertical"表示該布局下的元素垂直排列;
2、android:layout_gravity="center_horizontal"表示該布局在父布局里水平居中,此時(shí)其父布局必須擁有android:orientation="vertical"屬性;
3、android:layout_gravity="center_vertical"表示該布局在父布局里垂直居中,此時(shí)其父布局必須應(yīng)設(shè)置成android:orientation="horizontal"屬性(默認(rèn)為該屬性),且其父布局的高度應(yīng)設(shè)置為android:layout_height="fill_parent"屬性;
4、android:gravity="center_horizontal"表示該布局下的元素水平居中;

線性布局垂直水平居中布局文件實(shí)例:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  xmlns:tools="http://schemas.android.com/tools" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:orientation="vertical" > 
 
  <LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_gravity="center_horizontal" 
    > 
 
    <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:layout_gravity="center_vertical" 
      > 
 
      <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" > 
 
        <TextView 
          android:layout_width="100dp" 
          android:layout_height="wrap_content" 
          android:gravity="right" 
          android:text="用戶名" /> 
 
        <EditText 
          android:layout_width="300dp" 
          android:layout_height="wrap_content" /> 
      </LinearLayout> 
 
      <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" > 
 
        <TextView 
          android:layout_width="100dp" 
          android:layout_height="wrap_content" 
          android:gravity="right" 
          android:text="Email" /> 
 
        <EditText 
          android:layout_width="300dp" 
          android:layout_height="wrap_content" /> 
      </LinearLayout> 
    </LinearLayout> 
  </LinearLayout> 
</LinearLayout> 

相關(guān)文章

  • Android實(shí)現(xiàn)自定義飄雪效果

    Android實(shí)現(xiàn)自定義飄雪效果

    隨著冬季的腳步越來(lái)越遠(yuǎn),南方的我今年就看了一場(chǎng)雪,下一場(chǎng)雪遙遙無(wú)期,那我們來(lái)實(shí)現(xiàn)一個(gè)自定義的 View,它能模擬雪花飄落的景象,所以本文給大家介紹了基于Android實(shí)現(xiàn)自定義飄雪效果,感興趣的朋友可以參考下
    2024-01-01
  • Android如何高效顯示較大的Bitmaps

    Android如何高效顯示較大的Bitmaps

    這篇文章主要為大家詳細(xì)介紹了Android如何高效顯示較大Bitmaps的方法,感興趣的小伙伴們可以參考一下
    2016-05-05
  • android中intent傳遞list或者對(duì)象的方法

    android中intent傳遞list或者對(duì)象的方法

    這篇文章主要介紹了android中intent傳遞list或者對(duì)象的方法,分析羅列了常用的幾種方法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-01-01
  • Android ListView之EfficientAdapte的使用詳解

    Android ListView之EfficientAdapte的使用詳解

    這篇文章主要介紹了Android ListView之EfficientAdapte的使用詳解的相關(guān)資料,這里介紹EfficientAdapter 的使用方法,需要的朋友可以參考下
    2017-08-08
  • Android中比較兩個(gè)圖片是否一致的問(wèn)題

    Android中比較兩個(gè)圖片是否一致的問(wèn)題

    這篇文章主要介紹了Android中比較兩個(gè)圖片是否一致的問(wèn)題,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-10-10
  • Android編程使用自定義View實(shí)現(xiàn)水波進(jìn)度效果示例

    Android編程使用自定義View實(shí)現(xiàn)水波進(jìn)度效果示例

    這篇文章主要介紹了Android編程使用自定義View實(shí)現(xiàn)水波進(jìn)度效果,結(jié)合實(shí)例形式詳細(xì)分析了Android水波動(dòng)畫(huà)效果的具體實(shí)現(xiàn)步驟與相關(guān)注意事項(xiàng),需要的朋友可以參考下
    2017-01-01
  • 詳解Android 進(jìn)程

    詳解Android 進(jìn)程

    這篇文章主要介紹了Android 進(jìn)程的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)Android開(kāi)發(fā),感興趣的朋友可以了解下
    2020-08-08
  • Android啟動(dòng)頁(yè)廣告(騰訊廣告聯(lián)盟)解決方法及源碼下載

    Android啟動(dòng)頁(yè)廣告(騰訊廣告聯(lián)盟)解決方法及源碼下載

    這篇文章主要介紹了Android啟動(dòng)頁(yè)廣告(騰訊廣告聯(lián)盟)解決方法的相關(guān)資料,啟動(dòng)頁(yè)幾乎成為了每個(gè)app的標(biāo)配,有些商家在啟動(dòng)頁(yè)中增加了開(kāi)屏廣告以此帶來(lái)更多的收入,需要的朋友可以參考下
    2017-03-03
  • Android Notification實(shí)現(xiàn)動(dòng)態(tài)顯示通話時(shí)間

    Android Notification實(shí)現(xiàn)動(dòng)態(tài)顯示通話時(shí)間

    這篇文章主要為大家詳細(xì)介紹了Android Notification實(shí)現(xiàn)動(dòng)態(tài)顯示通話時(shí)間,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Android 實(shí)現(xiàn)仿網(wǎng)絡(luò)直播彈幕功能詳解及實(shí)例

    Android 實(shí)現(xiàn)仿網(wǎng)絡(luò)直播彈幕功能詳解及實(shí)例

    這篇文章主要介紹了Android 實(shí)現(xiàn)仿網(wǎng)絡(luò)直播彈幕功能詳解的相關(guān)資料,并附實(shí)例代碼及實(shí)現(xiàn)效果圖,需要的朋友可以參考下
    2016-11-11

最新評(píng)論