<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ?在布局優化中,Androi的官方提到了這三種布局、、,并介紹了這三種布局各有的優勢,下面也是簡單說一下他們的優勢,以及怎么使用,記下來權當做筆記。 ## 1、布局重用 標簽能夠重用布局文件,簡單的使用如下: ~~~ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width=”match_parent” android:layout_height=”match_parent” android:background="@color/app_bg" android:gravity="center_horizontal"> <include layout="@layout/titlebar"/> <TextView android:layout_width=”match_parent” android:layout_height="wrap_content" android:text="@string/hello" android:padding="10dp" /> ... </LinearLayout> ~~~ ? ? 1)標簽可以使用單獨的layout屬性,這個也是必須使用的。 ? ? 2)可以使用其他屬性。標簽若指定了ID屬性,而你的layout也定義了ID,則你的layout的ID會被覆蓋,[解決方案](http://my.eoe.cn/814017/archive/3415.html)。 ? ? 3)在include標簽中所有的android:layout_*都是有效的,前提是必須要寫layout_width和layout_height兩個屬性。 ? ? 4)布局中可以包含兩個相同的include標簽,引用時可以使用如下方法解決([參考](http://www.coboltforge.com/2012/05/tech-stuff-layout/)): ~~~ View bookmarks_container_2 = findViewById(R.id.bookmarks_favourite); bookmarks_container_2.findViewById(R.id.bookmarks_list); ~~~ ## 2、減少視圖層級 ? ? 標簽在UI的結構優化中起著非常重要的作用,它可以刪減多余的層級,優化UI。多用于替換FrameLayout或者當一個布局包含另一個時,標簽消除視圖層次結構中多余的視圖組。例如你的主布局文件是垂直布局,引入了一個垂直布局的include,這是如果include布局使用的LinearLayout就沒意義了,使用的話反而減慢你的UI表現。這時可以使用標簽優化。 ~~~ <merge xmlns:android="http://schemas.android.com/apk/res/android"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/add"/> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/delete"/> </merge> ~~~ ? ? ?現在,當你添加該布局文件時(使用標簽),系統忽略節點并且直接添加兩個Button。更多介紹可以參考《[Android Layout Tricks #3: Optimize by merging](http://android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-by.html)》 ## 3、需要時使用 ? ? 標簽最大的優點是當你需要時才會加載,使用他并不會影響UI初始化時的性能。各種不常用的布局想進度條、顯示錯誤消息等可以使用標簽,以減少內存使用量,加快渲染速度。是一個不可見的,大小為0的View。標簽使用如下: ~~~ <ViewStub android:id="@+id/stub_import" android:inflatedId="@+id/panel_import" android:layout="@layout/progress_overlay" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" /> ~~~ 當你想加載布局時,可以使用下面其中一種方法: ~~~ ((ViewStub) findViewById(R.id.stub_import)).setVisibility(View.VISIBLE); // or View importPanel = ((ViewStub) findViewById(R.id.stub_import)).inflate(); ~~~ 當調用inflate()函數的時候,ViewStub被引用的資源替代,并且返回引用的view。?這樣程序可以直接得到引用的view而不用再次調用函數findViewById()來查找了。 注:ViewStub目前有個缺陷就是還不支持??標簽。 更多標簽介紹可以參考《[Android Layout Tricks #3: Optimize with stubs](http://android-developers.blogspot.com/2009/03/android-layout-tricks-3-optimize-with.html)》
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看