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

詳解Android中weight的使用方法

 更新時(shí)間:2016年01月11日 09:20:43   作者:xu佳佳  
這篇文章主要向大家介紹了詳解Android中weight的使用方法,感興趣的小伙伴們可以參考一下

android中對(duì)weight的學(xué)習(xí)可以說是必須的,如果UI布局僅僅使用dp與sp等等,會(huì)讓布局顯得極度不靈活,畢竟各個(gè)手機(jī)屏幕大小不同,更別說是還有ipad之類的了,所以也是同做本人近期做的一個(gè)小UI來分享一下weight的使用。

    

  

左邊是各個(gè)屏幕的顯示效果,右邊是1080*1920屏幕的具體顯示效果??梢钥吹剑还芷聊蝗绾巫兓?,使用weight的布局中總是填充滿屏幕的,至于美觀效果就不說了,直接上代碼。

小編使用的android studio,eclipse用戶直接復(fù)制肯定會(huì)有問題,AS用戶直接復(fù)制修改一下中間的圖片便可以用啦。

<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:orientation="vertical"> 
 
  <RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.5" 
    android:background="#7EB345"> 
 
    <Button 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:background="@android:color/transparent" 
      android:drawableLeft="@drawable/left_menu" 
      android:paddingLeft="17dp" /> 
 
    <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:text="某某科技大學(xué)" 
      android:textSize="25sp" /> 
 
    <Button 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_alignParentRight="true" 
      android:background="@android:color/transparent" 
      android:text="登陸" 
      android:textColor="#fff" 
      android:textSize="20sp" /> 
 
  </RelativeLayout> 
 
  <TextView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1.5" 
    android:background="@drawable/school" /> 
 
 
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:orientation="horizontal"> 
 
    <Button 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/transparent" 
      android:drawableTop="@mipmap/ic_launcher" 
      android:paddingTop="18dp" 
      android:text="校園新聞" /> 
 
    <Button 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/transparent" 
      android:drawableTop="@mipmap/ic_launcher" 
      android:paddingTop="18dp" 
      android:text="學(xué)術(shù)公告" /> 
 
    <Button 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/transparent" 
      android:drawableTop="@mipmap/ic_launcher" 
      android:paddingTop="18dp" 
      android:text="成績(jī)查詢" /> 
  </LinearLayout> 
 
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:orientation="horizontal"> 
 
    <Button 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/transparent" 
      android:drawableTop="@mipmap/ic_launcher" 
      android:paddingTop="18dp" 
      android:text="課表信息" /> 
 
    <Button 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/transparent" 
      android:drawableTop="@mipmap/ic_launcher" 
      android:paddingTop="18dp" 
      android:text="圖書借閱" /> 
 
    <Button 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/transparent" 
      android:drawableTop="@mipmap/ic_launcher" 
      android:paddingTop="18dp" 
      android:text="飯卡消費(fèi)" /> 
  </LinearLayout> 
 
  <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:orientation="horizontal"> 
 
    <Button 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/transparent" 
      android:drawableTop="@mipmap/ic_launcher" 
      android:paddingTop="18dp" 
      android:text="校園地圖" /> 
 
    <Button 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/transparent" 
      android:drawableTop="@mipmap/ic_launcher" 
      android:paddingTop="18dp" 
      android:text="在線咨詢" /> 
 
    <Button 
      android:id="@+id/neirongbuju" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/transparent" 
      android:drawableTop="@mipmap/ic_launcher" 
      android:paddingTop="18dp" 
      android:text="查看更多" /> 
  </LinearLayout> 
 
  </LinearLayout> 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。

相關(guān)文章

最新評(píng)論