日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

Android Shape 的使用

發布時間:2023/11/27 生活经验 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android Shape 的使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

學而時習,溫故而知新。

今天復習shape 畫各種常見類型的背景圖

使用:

當在?java 代碼R.drawable.文件的名稱

當在布局中時 android:background=“@drawable/文件的名字”

?

位置在

res下面的drawable 里面

?

1 先看下shape可以指定幾種類型

line 線行

oval 橢圓?

rectangle 長方形

ring 環行

2 shape 里面常用的屬性

2.1 corners 圓角 

角度可以單獨四個角 指定如下圖

2.2? solid 填充屬性 ,一般我們設置顏色,線的寬度 里面的屬性一般就是color?

2.3 stock 邊的屬性?

里面的屬性如下

2.4?size 大小設置 一般是設置畫的背景大小

2.5 gradient 漸變屬性,一般畫顏色不同的背景 屬性如下

2.6 padding 這個就是邊距屬性

顯示畫一些背景

1 帶有圓角的長方形

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"><corners android:radius="10dp" /><solid android:color="@color/colorAccent" /><sizeandroid:width="200dp"android:height="44dp" /></shape>

效果圖

2 畫一個帶邊線的長方形

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"><corners android:radius="10dp" /><stroke android:color="@color/colorAccent" android:width="1dp" ><sizeandroid:width="200dp"android:height="44dp" /></shape>

?

效果圖

?

3 上面2個圓角的長方形

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"><cornersandroid:topLeftRadius="20dp"android:topRightRadius="20dp" /><solid android:color="@color/colorAccent" /></shape>

效果圖

4 畫一個漸變色的背景圖

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"><gradientandroid:centerColor="#4A63FF"android:endColor="#6320DE"android:startColor="#558EFB" /><sizeandroid:width="200dp"android:height="100dp" />
</shape>

效果圖

?

5 畫一個圓

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="oval"><solid android:color="@color/colorAccent" /><sizeandroid:width="200dp"android:height="200dp" />
</shape>

效果圖

6 畫一個圓環

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="oval"><strokeandroid:width="10dp"android:color="@color/colorAccent" /><sizeandroid:width="200dp"android:height="200dp" />
</shape>

效果圖

?

7 畫一個有虛線組成的圓

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="oval"><strokeandroid:width="10dp"android:color="@color/colorAccent"android:dashGap="5dp"android:dashWidth="5dp"/><sizeandroid:width="200dp"android:height="200dp" />
</shape>

效果圖

修改屬性?

8 變成虛線的長方形

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><strokeandroid:width="10dp"android:color="@color/colorAccent"android:dashGap="5dp"android:dashWidth="50dp"/><sizeandroid:width="400dp"android:height="200dp" />
</shape>

效果圖

?

?9 改成橢圓

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="oval"><strokeandroid:width="10dp"android:color="@color/colorAccent"android:dashGap="5dp"android:dashWidth="50dp"/><sizeandroid:width="400dp"android:height="200dp" />
</shape>

效果圖

10 畫一個半圓

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><cornersandroid:topLeftRadius="180dp"android:topRightRadius="180dp" /><solid android:color="@color/colorAccent" /><sizeandroid:width="400dp"android:height="200dp" />
</shape>

?效果圖

?

總結

以上是生活随笔為你收集整理的Android Shape 的使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。