<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                視頻鏈接 : http://www.imooc.com/video/10165 1.看第一個例子,當我們按比例放置多個TextView時,在沒有添加內容或者內容沒有超過分配的寬度時,這些TextView會很正常的顯示在屏幕上,但是當某一個TextView 的內容寬度多于分配的寬度時, 就會 出現 如下情況。 ~~~ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="48dp" android:layout_weight="1" android:background="@color/person_center_item1" android:gravity="center" android:text="1234646156" /> <TextView android:layout_width="0dp" android:layout_height="48dp" android:layout_weight="2" android:background="@color/person_center_item2" android:gravity="center" android:text="2" /> <TextView android:layout_width="0dp" android:layout_height="48dp" android:layout_weight="3" android:background="@color/person_center_item3" android:gravity="center" android:text="3" /> </LinearLayout> ~~~ ![](https://box.kancloud.cn/2016-02-23_56cbd2db5f8e0.jpg) 出現這種情況是因為 他們的對齊當時是根據父控件的基線進行對齊的,很明顯的可以看到123..... 和 2 ,3 的下邊界是在一條線上的。解決這種問題 只要這 ?上面代碼的LinearLayout 中添加如下代碼就可以了。android:baselineAligned="false" ![](https://box.kancloud.cn/2016-02-23_56cbd2db7d1ba.jpg) 2.當我們把上面代碼 的第一個TextView 改成?wrap_content?之后?,我們會發現 第一個TextView 原本只占1/6寬度的,現在卻占了一半左右的寬度。這是為什么呢? ![](https://box.kancloud.cn/2016-02-23_56cbd2db92d92.jpg) 這是因為在分配寬度的時候 ,首先會給每個TextView分配他們自己layout_width 值的寬度,然后將剩下的按照比列依次加給3個控件。 3.然后我們把3個TextView的寬度全部改成?match_parent,然后我們發現屏幕上只有第一、二個TextView了,第三個不見了。這又是為什么呢? ![](https://box.kancloud.cn/2016-02-23_56cbd2dbb0870.jpg) 原因和第2點一樣,首先給每個TextView分配?match_parent的寬度,然后再把剩下的寬度加到每個控件上。我們假設屏幕寬度為480, 第一次分配的寬度為 480 * 3; 然后 用屏幕寬度 減去 第一次分配的寬度,也就是480-480*3 得到的是 -960, 然后把 -960 分成6份. 1/6 加到第一個TextView上: 480 +(-960 /6) = 320; 2/6 加到第一個TextView上: 480 +(-960 /6)* 2 = 160; 3/6 加到第一個TextView上: 480 +(-960 /6)* 3 = 0; 第三個TextView為0,所以不顯示。 4.當我們想在LinearLayout中讓一個TextView 占一半屏幕寬度的時候,我們可以這樣做:讓TextView的layout_weight值為1,或者其他你喜歡的,然后在父控件LinearLayout中聲明?**android****:weightSum=****"2"**或者自己定義值得2倍就OK了!效果如下。 ?? ![](https://box.kancloud.cn/2016-02-23_56cbd2dbcd919.jpg) 5.對于以 layout_XXX,這樣格式的屬性設置,這些屬性是交給父控件去分配的 ,像layout_width、layout_height等,像layout_gravity="center",就是 將該控件置于父控件的中心位置。而那些沒有以layout_開始的屬性則是控件自身控制和分配的。
                  <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>

                              哎呀哎呀视频在线观看