android UI布局

來源:互聯網
上載者:User

標籤:android   style   http   color   使用   io   檔案   art   

一、設定重複背景
在drawable檔案夾下建一個mybackground.xml檔案在檔案中寫入:<?xml version="1.0" encoding="utf-8"?><bitmap xmlns:android="http://schemas.android.com/apk/res/android"    android:src="@drawable/mybg_img"    android:tileMode="repeat"/>

tileMode 屬性就是用於定義背景的顯示模式: 

        disabled 預設值,表示不使用平鋪

        clamp 複製邊緣色彩

        repeat X、Y 軸進行重複圖片顯示,也就是我們說要說的平鋪 

        mirror 在水平和垂直方向上使用交替鏡像的方式重複圖片的繪製


二、使用layer-list組合圖片

同樣的在drawable檔案夾下建一個mylayerlist.xml檔案

在檔案中寫入:

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

<item> 

    <bitmap android:src="@drawable/sms_top_bg" 

        android:gravity="center"/> 

</item> 

<item> 

<bitmap android:src="@drawable/sms_list_selected_arrow" 

android:gravity="right"/> 

</item> 

</layer-list>

其中的bitmap中只能加圖片,而且檔案不會對圖片進行處理(顯示的是原始的圖片)。如所示(layer-list組合的是藍色圖片加上右邊的小箭頭):


在<item></item>中可以直接加入<shape></shape>

如下所示:

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

<item> 

    <shape>

 <gradient

      android:startColor="#FFFFFF"

      android:endColor="#CAFF70"

      android:type="linear"

      android:angle="90"/>

 <padding android:left="0dp"

      android:top="0dp"

      android:right="0dp"

      android:bottom="0dp" />

 <corners

     android:topRightRadius="6dp"

     android:topLeftRadius="6dp"

     android:bottomLeftRadius="6dp"

     android:bottomRightRadius="6dp"/>

     </shape>

</item> 

<item> 

<bitmap android:src="@drawable/sms_list_selected_arrow" 

android:gravity="right"/> 

</item> 

</layer-list>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.