最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

詳解Android中weight的使用方法

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

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

    

  

左邊是各個(gè)屏幕的顯示效果,右邊是1080*1920屏幕的具體顯示效果??梢钥吹?,不管屏幕如何變化,使用weight的布局中總是填充滿(mǎn)屏幕的,至于美觀效果就不說(shuō)了,直接上代碼。

小編使用的android studio,eclipse用戶(hù)直接復(fù)制肯定會(huì)有問(wèn)題,AS用戶(hù)直接復(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ī)查詢(xún)" /> 
  </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="圖書(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="飯卡消費(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="在線咨詢(xún)" /> 
 
    <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)文章

  • Android中使用socket使底層和framework通信的實(shí)現(xiàn)方法

    Android中使用socket使底層和framework通信的實(shí)現(xiàn)方法

    native和framework的通信是通過(guò)jni,但是這一般只是framework調(diào)用native,native如果有消息要怎樣通知上層 呢?android中GSP模塊提供一種解決思路,但是實(shí)現(xiàn)有些復(fù)雜,這里介紹一種使用socket通信的方法可以使native和framework自由通信,感興趣的朋友一起看看吧
    2016-11-11
  • Android中檢查、設(shè)置默認(rèn)程序詳解

    Android中檢查、設(shè)置默認(rèn)程序詳解

    這篇文章主要介紹了Android中檢查、設(shè)置默認(rèn)程序詳解,本文講解了檢測(cè)是否有默認(rèn)的程序、如果有默認(rèn)程序、沒(méi)有默認(rèn)的程序的情況等內(nèi)容,需要的朋友可以參考下
    2015-01-01
  • Android開(kāi)發(fā)事件處理的代碼如何寫(xiě)手摸手教程

    Android開(kāi)發(fā)事件處理的代碼如何寫(xiě)手摸手教程

    這篇文章主要為大家介紹了Android開(kāi)發(fā)事件處理的代碼如何寫(xiě)手摸手教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • Android使用SoundPool播放音效

    Android使用SoundPool播放音效

    這篇文章主要為大家詳細(xì)介紹了Android使用SoundPool播放音效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • Android自定義View實(shí)現(xiàn)左右滑動(dòng)選擇出生年份

    Android自定義View實(shí)現(xiàn)左右滑動(dòng)選擇出生年份

    這篇文章主要介紹了Android自定義View實(shí)現(xiàn)左右滑動(dòng)選擇出生年份,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-06-06
  • Android內(nèi)存泄漏檢測(cè)工具LeakCanary

    Android內(nèi)存泄漏檢測(cè)工具LeakCanary

    在Android的性能優(yōu)化中,內(nèi)存優(yōu)化是必不可少的點(diǎn),而內(nèi)存優(yōu)化最重要的一點(diǎn)就是解決內(nèi)存泄漏的問(wèn)題,在Android的內(nèi)存泄漏分析工具也不少,比如PC端的有:AndroidStudio自帶的Android?Profiler、MAT等工具;手機(jī)端也有,就是我們今天要介紹的LeakCanary
    2023-04-04
  • 解決Eclipse啟動(dòng)出錯(cuò):Failed to create the Java Virtual Machine

    解決Eclipse啟動(dòng)出錯(cuò):Failed to create the Java Virtual Machine

    這篇文章主要介紹了解決Eclipse啟動(dòng)出錯(cuò):Failed to create the Java Virtual Machine的相關(guān)資料,這里說(shuō)明出錯(cuò)原因及查找錯(cuò)誤和解決辦法,需要的朋友可以參考下
    2017-07-07
  • android流式布局onLayout()方法詳解

    android流式布局onLayout()方法詳解

    這篇文章主要為大家詳細(xì)介紹了android流式布局的onLayout()方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • Android基礎(chǔ)知識(shí)之frame動(dòng)畫(huà)效果

    Android基礎(chǔ)知識(shí)之frame動(dòng)畫(huà)效果

    Android基礎(chǔ)知識(shí)之tween動(dòng)畫(huà)效果,Android一共提供了兩種動(dòng)畫(huà),這篇文章主要介紹了Android動(dòng)畫(huà)效果之frame動(dòng)畫(huà),感興趣的小伙伴們可以參考一下
    2016-06-06
  • Android性能優(yōu)化之plt?hook與native線程監(jiān)控詳解

    Android性能優(yōu)化之plt?hook與native線程監(jiān)控詳解

    這篇文章主要為大家介紹了Android性能優(yōu)化之plt?hook與native線程監(jiān)控詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09

最新評(píng)論

修文县| 绥滨县| 南澳县| 长宁区| 临安市| 邯郸市| 东乌珠穆沁旗| 张掖市| 苍南县| 黑山县| 贵港市| 和田县| 田阳县| 宁阳县| 慈利县| 台州市| 贵定县| 鸡西市| 黄浦区| 密山市| 美姑县| 西宁市| 武定县| 恩平市| 集安市| 象州县| 上饶市| 慈利县| 杭锦后旗| 布拖县| 谷城县| 平度市| 洛宁县| 双辽市| 肇源县| 清镇市| 阳西县| 汤阴县| 延庆县| 玉林市| 贵南县|