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

Android開發(fā)之merge結合include優(yōu)化布局

 更新時間:2016年06月11日 16:57:05   作者:_江南一點雨  
這篇文章主要為大家詳細介紹了Android開發(fā)之merge結合include優(yōu)化布局,感興趣的朋友可以參考一下

merge結合include優(yōu)化android布局,效果不知道,個人感覺使用上也有很大的局限,不過還是了解一下,記錄下來。

布局文件都要有根節(jié)點,但android中的布局嵌套過多會造成性能問題,于是在使用include嵌套的時候我們可以使用merge作為根節(jié)點,這樣可以減少布局嵌套,提高顯示速率。

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >

 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="張三" />

 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="李四" />

 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="王五" />

</merge>

上面的界面在顯示的時候會自動嵌套到下面的文件中。

<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="horizontal"
 tools:context="com.example.viewstub.MainActivity" >

 <include layout="@layout/top"/>
 <TextView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="@string/hello_world" />

 <Button
  android:id="@+id/toggle"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:onClick="onClick"
  android:text="顯示/隱藏" />

 <ViewStub
  android:id="@+id/vs"
  android:layout_margin="50dp"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:inflatedId="@+id/inflated_id"
  android:layout="@layout/view_stub_layout" />

</LinearLayout>

我為什么說這個局限性比較大呢?因為merge中的空間顯示的使用會采用主布局文件的方式來顯示,比如我這里主布局是linearlayout且是水平排列,那么merge中的元素顯示出來之后也是水平排列,可是我如果想讓merge中的元素垂直排列呢?抱歉,做不到。

原文鏈接:http://blog.csdn.net/u012702547/article/details/47133647

以上就是本文的全部內(nèi)容,希望對大家學習Android軟件編程有所幫助。 

相關文章

  • Android自定義View實現(xiàn)星星評分效果

    Android自定義View實現(xiàn)星星評分效果

    這篇文章主要為大家詳細介紹了Android如何利用自定義View實現(xiàn)一個星星評分的控件,文中的示例代碼講解詳細,感興趣的小伙伴可以嘗試一下
    2022-11-11
  • Android 仿QQ頭像自定義截取功能

    Android 仿QQ頭像自定義截取功能

    在我們的qq聊天工具中,經(jīng)常會使用qq頭像截取功能,基于代碼是怎么實現(xiàn)的呢?下面小編通過本文給大家分享android 仿qq頭像自定義截取功能的思路分析及編碼實現(xiàn)過程,感興趣的朋友一起學習吧
    2016-10-10
  • Android實現(xiàn)可播放GIF動畫的ImageView

    Android實現(xiàn)可播放GIF動畫的ImageView

    這篇文章主要為大家詳細介紹了Android實現(xiàn)可播放GIF動畫的ImageView,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • 詳解android是如何管理內(nèi)存的

    詳解android是如何管理內(nèi)存的

    這篇文章主要介紹了詳解android是如何管理內(nèi)存的,幫助大家更好的理解和學習使用Android,感興趣的朋友可以了解下
    2021-03-03
  • Android開發(fā)設計nowinandroid構建腳本學習

    Android開發(fā)設計nowinandroid構建腳本學習

    這篇文章主要為大家介紹了Android開發(fā)設計nowinandroid構建腳本學習,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-11-11
  • 如何安裝adb工具及常用的adb命令

    如何安裝adb工具及常用的adb命令

    ADB全稱為Android Debug Bridge,起到調(diào)試橋的作用,是一個客戶端-服務器端程序,ADB 也是 Android SDK 中的一個工具,可以直接操作管理 Android 模擬器或者真實的 Android 設備,本文介紹如何安裝adb工具及常用的adb命令,感興趣的朋友一起看看吧
    2024-01-01
  • android基礎教程之context使用詳解

    android基礎教程之context使用詳解

    Android中context可以作很多操作,但是最主要的功能是加載和訪問資源,下面詳解了解一下它的使用方法
    2014-02-02
  • Android 中Volley二次封裝并實現(xiàn)網(wǎng)絡請求緩存

    Android 中Volley二次封裝并實現(xiàn)網(wǎng)絡請求緩存

    這篇文章主要介紹了Android 中Volley二次封裝并實現(xiàn)網(wǎng)絡請求緩存的相關資料,希望通過本文能幫助到大家,徹底會使用Volley,需要的朋友可以參考下
    2017-09-09
  • Android編程實現(xiàn)識別與掛載U盤的方法

    Android編程實現(xiàn)識別與掛載U盤的方法

    這篇文章主要介紹了Android編程實現(xiàn)識別與掛載U盤的方法,對比分析了Android針對U盤的識別與掛載技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2016-02-02
  • Android中利用App實現(xiàn)消息推送機制的代碼

    Android中利用App實現(xiàn)消息推送機制的代碼

    Android中利用App實現(xiàn)消息推送機制的代碼,需要的朋友可以參考下。
    2011-05-05

最新評論