欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android中shape的自定義藝術(shù)效果使用

 更新時(shí)間:2022年01月28日 14:38:01   作者:xiyangyang8110  
大家好,本篇文章主要講的是Android中shape的自定義藝術(shù)效果使用,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下

shape形狀之意,可自定義各種形狀,如背景橢圓,圓角等等

創(chuàng)建目錄:drawable–右鍵–new–drawable resourse file–鍵入文件名my_shape–ok–修改selector標(biāo)簽為shape

在這里插入圖片描述

1圓角

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:radius="10dp"/>

</shape>

引用:android:background="@drawable/my_shape"

<Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="148dp"
        android:layout_marginTop="102dp"
        android:background="@drawable/my_shape"
        android:text="Button"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

在這里插入圖片描述

2 單獨(dú)控制某個(gè)圓角,如左上,右下。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:topLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        />

</shape>

在這里插入圖片描述

3 圓形背景

前提button寬高一樣,圓角大小為button的一半大

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:radius="100dp"/>

</shape>
 <Button
        android:id="@+id/button"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_marginStart="148dp"
        android:layout_marginTop="102dp"
        android:background="@drawable/my_shape"
        android:text="Button"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

在這里插入圖片描述

3 描邊效果
注意此時(shí)用textview引用,botton無(wú)效
solid:實(shí)體,可設(shè)置主體顏色
stroke:描邊,dashWidth虛線寬度,dashGap虛線間的距離

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
        android:radius="50dp"/>
    <size
        android:height="100dp"
        android:width="100dp"/>
    <solid
        android:color="#FF4081"/>
    <stroke
        android:width="5dp"
        android:color="#3F51B5"
        android:dashWidth="20dp"
        android:dashGap="10dp"/>

</shape>

引用

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="148dp"
        android:layout_marginTop="102dp"
        android:background="@drawable/my_shape"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

在這里插入圖片描述

4漸變色
gradient:傾斜度,標(biāo)簽實(shí)現(xiàn)
紅綠藍(lán)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#ff0000"
        android:centerColor="#00ff00"
        android:endColor="#0000ff"
        />

</shape>

引用

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="148dp"
        android:layout_marginTop="102dp"
        android:text="Hello world"
        android:background="@drawable/my_shape_gradient"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

在這里插入圖片描述

拓展
1gradient標(biāo)簽?zāi)J(rèn)類(lèi)型是線性的android:type=“linear”,還有一種炫酷的效果是掃射sweep

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#ff0000"
        android:centerColor="#00ff00"
        android:endColor="#0000ff"
        android:type="sweep"
        />

</shape>

在這里插入圖片描述

2確定逆時(shí)針旋轉(zhuǎn)的角度angle屬性,如android:angle="90"表示逆時(shí)針轉(zhuǎn)90度

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#ff0000"
        android:centerColor="#00ff00"
        android:endColor="#0000ff"
        android:angle="90"
        android:type="linear"
        />

</shape>

在這里插入圖片描述

最后來(lái)一個(gè)好叼的樣子

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="@color/black"
        android:endColor="@color/black"
        android:centerColor="#FFFFFF"
        android:type="sweep"/>

</shape>

在這里插入圖片描述

到此這篇關(guān)于Android中shape的自定義藝術(shù)效果使用的文章就介紹到這了,更多相關(guān)Android shape內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Android中Fragment 重疊遮蓋問(wèn)題解決辦法

    Android中Fragment 重疊遮蓋問(wèn)題解決辦法

    這篇文章主要介紹了Android中Fragment 重疊遮蓋問(wèn)題解決辦法的相關(guān)資料,需要的朋友可以參考下
    2017-05-05
  • android 瀏覽器之多窗口方案詳解

    android 瀏覽器之多窗口方案詳解

    android 瀏覽器之多窗口方案詳細(xì)介紹,需要的朋友可以過(guò)來(lái)參考下
    2013-07-07
  • PHP autoload 機(jī)制詳解

    PHP autoload 機(jī)制詳解

    本文主要介紹 PHP autoload 機(jī)制,這里整理了詳細(xì)的知識(shí)資料供大家學(xué)習(xí)參考,希望能幫助有需要的小伙伴
    2016-08-08
  • Android  CalendarView,DatePicker,TimePicker,以及NumberPicker的使用

    Android CalendarView,DatePicker,TimePicker,以及NumberPicker的使

    這篇文章主要介紹了Android CalendarView,DatePicker,TimePicker,以及NumberPicker的使用的相關(guān)資料,需要的朋友可以參考下
    2016-12-12
  • Android軟鍵盤(pán)狀態(tài)彈出與消失的示例

    Android軟鍵盤(pán)狀態(tài)彈出與消失的示例

    這篇文章主要介紹了本篇文章主要介紹了Android軟鍵盤(pán)狀態(tài)彈出與消失的示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-02-02
  • Android使用SqLite實(shí)現(xiàn)登錄注冊(cè)功能流程詳解

    Android使用SqLite實(shí)現(xiàn)登錄注冊(cè)功能流程詳解

    這篇文章主要介紹了使用Android Studio自帶的sqlite數(shù)據(jù)庫(kù)實(shí)現(xiàn)一個(gè)簡(jiǎn)單的登錄注冊(cè)功能,SQLite是一個(gè)軟件庫(kù),實(shí)現(xiàn)了自給自足的、無(wú)服務(wù)器的、零配置的、事務(wù)性的SQL數(shù)據(jù)庫(kù)引擎,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2023-12-12
  • Android Google AutoService框架使用詳解

    Android Google AutoService框架使用詳解

    AutoService是Google開(kāi)發(fā)一個(gè)自動(dòng)生成SPI清單文件的框架??催^(guò)一些基于APT的三方框架源碼的讀者應(yīng)該有所了解。比如Arouter、EventBus等等
    2022-11-11
  • Android切面編程入門(mén)講解

    Android切面編程入門(mén)講解

    這篇文章給大家分享了關(guān)于Android進(jìn)階資深開(kāi)發(fā)必備技能-切面編程入門(mén)的相關(guān)知識(shí)點(diǎn)內(nèi)容,有興趣的朋友們參考下。
    2018-08-08
  • android隱式意圖激活瀏覽器的實(shí)現(xiàn)方法

    android隱式意圖激活瀏覽器的實(shí)現(xiàn)方法

    下面小編就為大家?guī)?lái)一篇android隱式意圖激活瀏覽器的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-06-06
  • Android自定義View圖片按Path運(yùn)動(dòng)和旋轉(zhuǎn)

    Android自定義View圖片按Path運(yùn)動(dòng)和旋轉(zhuǎn)

    這篇文章主要為大家詳細(xì)介紹了Android自定義View圖片按Path運(yùn)動(dòng)和旋轉(zhuǎn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-01-01

最新評(píng)論