Android:res之shape製作圓角、虛線、漸層

來源:互聯網
上載者:User

標籤:

xml控制項配置屬性

android:background="@drawable/shape"

標籤

corners ----------圓角
gradient ----------漸層
padding ----------內容離邊界距離
size ------------大小 
solid  ----------填充顏色
stroke ----------描邊

 

注意的是corners的屬性bottomLeftRadius為右下角、bottomRightRadius為左下角

 

 

shape製作圓角

<Button     android:layout_width="160dp"    android:layout_height="wrap_content"    android:background="@drawable/button_shape"    android:text="圓角按鈕"    />
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >    <solid android:color="#fff"/>    <padding android:top="10px" android:bottom="10px"/>    <corners android:radius="16px"/>    <stroke android:width="1px" android:color="#000"/></shape>

shape製作虛線

沒有dashGap屬性則為實線

 

<View     android:layout_width="match_parent"    android:layout_height="5px"    android:layout_marginTop="10dp"    android:background="@drawable/line_shape"    />
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="line" >    <stroke        android:dashGap="3dp"        android:dashWidth="8dp"        android:width="1dp"        android:color="#63a219" />    <size android:height="1dp" /></shape>

shape製作漸層

<View     android:layout_width="match_parent"    android:layout_height="50dp"    android:layout_marginTop="10dp"    android:background="@drawable/gra_shape"    />
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >    <gradient        android:angle="270.0"        android:endColor="#ffffff"        android:startColor="#000000" /></shape>

Android:res之shape製作圓角、虛線、漸層

聯繫我們

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