圓角邊框和漸層,圓角邊框漸層

來源:互聯網
上載者:User

圓角邊框和漸層,圓角邊框漸層

 

Demo2\aa\src\main\res\drawable\bg_border.xml

1 <?xml version="1.0" encoding="utf-8"?>2 <shape xmlns:android="http://schemas.android.com/apk/res/android">3     <!--設定背景色為透明色-->4     <solid android:color="#0000"/>5     <!--設定紅色邊框-->6     <stroke android:width="4dp" android:color="#f00"/>7 </shape>

 

Demo2\aa\src\main\res\drawable\bg_border2.xml

 1 <?xml version="1.0" encoding="utf-8"?> 2 <shape xmlns:android="http://schemas.android.com/apk/res/android" 3     android:shape="rectangle"> 4     <!--指定圓角矩形的4個圓角的半徑--> 5     <corners 6         android:bottomLeftRadius="5dp" 7         android:bottomRightRadius="20dp" 8         android:topLeftRadius="20dp" 9         android:topRightRadius="5dp" />10     <!--指定邊框線條的寬度和顏色-->11     <stroke12         android:width="4dp"13         android:color="#f0f" />14     <!--指定使用漸層背景色,使用sweep類型的漸層(紅綠藍)-->15     <gradient16         android:centerColor="#0f0"17         android:endColor="#00f"18         android:startColor="#f00"19         android:type="sweep" />20 </shape>

 

Demo2\aa\src\main\res\layout\activity_main.xml

 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2     xmlns:tools="http://schemas.android.com/tools" 3     android:layout_width="match_parent" 4     android:layout_height="match_parent" 5     android:orientation="vertical" 6     tools:context=".MainActivity"> 7  8     <!--通過background指定背景--> 9     <TextView10         android:layout_width="match_parent"11         android:layout_height="wrap_content"12         android:text="帶邊框的文本"13         android:textSize="24sp"14         android:background="@drawable/bg_border"/>15     <TextView16         android:layout_width="match_parent"17         android:layout_height="wrap_content"18         android:text="圓角邊框,漸層背景的文本"19         android:textSize="24sp"20         android:background="@drawable/bg_border2"/>21 22 </LinearLayout>

 

聯繫我們

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