Android常見布局問題

來源:互聯網
上載者:User

標籤:

好久沒寫博了,因為最近在忙著做一個app,實在是沒有時間。現在快完工了。想著還是把這個布局問題說一下,相信很多人都遇到了,而且但凡是寫的稍微複雜一點的layout,遇到的不止一次。

對於一個強迫症的人來說,看見這個2,立馬想讓它消失。開啟lint一看,全是同一個問題,如下:

意思大概是丟失了關於image的說明,那就手動給它添加一條唄。android:contentDescription="@string/value"

其他:

  • Set android:baselineAligned="false" on this element for better performance
    • 如果LinearLayout被用於嵌套的layout空間計算,它的android:baselineAligned屬性應該設定成false,以加速layout計算
    • android:baselineAligned="false"
  • This LinearLayout layout or its RelativeLayout parent is useless;
    • 多餘的Linearlayout或者RelativeLayout
    • 刪除即可
  • This tag and its children can be replaced by one <TextView/> and a compound   drawable
    • 有時候我們可能會用image+textview組合,但其實image是沒必要的,textview提供了一個屬性來給它設定image
    • android:drawable="@drawable/resource"
  • Use a layout_height of 0dip instead of wrap_content for better   performance
    • 當在一個linearlayout布局中為一個控制項設定weight屬性時,這個組件會預設填充剩餘空間
    • 去掉weight屬性或者修改wrap_content為0dp
  • Buttons in button bars should be borderless
    • 原因未知
    • style="?android:attr/buttonBarButtonStyle"

Android常見布局問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.