android畫圖—–shape的使用

來源:互聯網
上載者:User

轉;http://wang-peng1.iteye.com/blog/523869

在GradientDrawable1試圖中終於把shape學會了,以前總是似懂非懂,現在終於把裡面的東西搞清楚了,同時也挺佩服Google的用心,故意設定一些陷阱吧,不認真對待還真以為沒有啥效果呢。 
setContentView(R.layout.shape_drawable_1) 
shape_drawable_1 代碼如下: 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"> 

    <LinearLayout 
    android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"> 
    
<ImageView 
android:layout_width="fill_parent" 
android:layout_height="50dip" 
android:src="@drawable/shape_1" /> 

<ImageView 
android:layout_width="fill_parent" 
android:layout_height="50dip" 
android:src="@drawable/line" /> 

<ImageView 
android:layout_width="fill_parent" 
android:layout_height="50dip" 
android:src="@drawable/shape_2" /> 

<ImageView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:src="@drawable/line" /> 
  
<ImageView 
android:layout_width="fill_parent" 
android:layout_height="50dip" 
android:src="@drawable/shape_3" /> 

<ImageView 
android:layout_width="fill_parent" 
android:layout_height="20dip" 
android:src="@drawable/line" /> 

<ImageView 
android:layout_width="fill_parent" 
android:layout_height="50dip" 
android:src="@drawable/shape_4" /> 

<ImageView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:src="@drawable/line" /> 

<ImageView 
android:layout_width="fill_parent" 
android:layout_height="50dip" 

android:src="@drawable/shape_5" /> 

</LinearLayout> 
</ScrollView> 
shape_5的代碼: 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> 
    <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF" 
            android:angle="270"/> 
    <padding android:left="50dp" android:top="20dp" 
            android:right="7dp" android:bottom="7dp" /> 
    <corners android:radius="8dp" /> 
    
</shape> 
gradient  產生色彩坡形  android:angle 從哪個角度開始變 貌似只有90的整數倍可以 
android:shape="rectangle" 預設的也是長方形 

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> 
    <solid android:color="#ff4100ff"/> 
    <stroke android:width="2dp" android:color="#ee31ff5e" 
            android:dashWidth="3dp" android:dashGap="2dp" /> 
    <padding android:left="7dp" android:top="7dp" 
            android:right="7dp" android:bottom="7dp" /> 
    <corners android:radius="6dp" /> 
</shape> 

#ff4100ff藍色#ff4100ff綠色 
     <solid android:color="#ff4100ff"/>實心的 填充裡面 
     <stroke 描邊 採用那樣的方式將外形輪廓線畫出來 

android:dashWidth="3dp" android:dashGap="2dp" 預設值為0 

android:width="2dp" android:color="#FF00ff00"筆的粗細, 
       android:dashWidth="5dp" android:dashGap="5dp" 實現- - -這樣的效果,dashWidth指的是一條小橫線的寬度 
       dashGap 指的是 小橫線與小橫線的間距。 width="2dp" 不能太寬

聯繫我們

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