導航:首頁 > 操作系統 > androidshape實心圓

androidshape實心圓

發布時間:2022-08-10 16:12:15

『壹』 android中怎麼繪制這種圓形布局

圓形是個背景,可以通過xml定義背景圖片
在res/drawable/下添加背景xml,test.xml代碼如下

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item >

<shape android:shape="oval">

<padding android:top="2dp" android:right="2dp" android:bottom="2dp" android:left="2dp" />

<solid android:color="#00a0eb"/>

</shape>

</item>

<item >

<shape android:shape="oval">

<solid android:color="#ffffffff"/>

</shape>

</item>

</layer-list>

然後在layout下添加布局文件

代碼如下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context="indi.zcm.dropdown.MainActivity" >



<RelativeLayout

android:layout_width="100dp"

android:layout_height="100dp"

android:background="@drawable/test">


<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentTop="true"

android:layout_centerHorizontal="true"

android:layout_marginTop="27dp"

android:text="購買人數" />


<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentTop="true"

android:layout_centerHorizontal="true"

android:layout_marginTop="45dp"

android:textSize="26sp"

android:text="32514" />

</RelativeLayout>

</RelativeLayout>

這個應該就是你要的效果

『貳』 android怎樣在代碼中創建shape圓oval

  1. 在drawable文件夾中創建bg_oval_shape.xml的xml文件

  2. 文件中添加如下代碼

<?xmlversion="1.0"encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#676767"/>

</shape>

3.在需要添加oval的控制項中引用,代碼如下:

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

『叄』 android 圓角樣式shape 的shape屬性什麼意思

shape官方給出了很多屬性的解釋,如下:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
><!-- 其中rectagle表示矩形,oval表示橢圓,line表示水平直線,ring表示環形 -->
<!-- 節點屬性介紹如下 -->
<corners />
<!-- 節點1:corners (圓角)
android:radius 圓角的半徑 值越大角越圓
android:topLeftRadius 左上圓角半徑
android:topRightRadius 右上圓角半徑
android:bottomLeftRadius 左下圓角半徑
android:bottomRightRadius 右下圓角半徑
-->

<gradient />
<!-- 節點2: gradient (背景顏色漸變)
android:startColor 起始顏色
android:centerColor 中間顏色
android:endColor 末尾顏色
android:angle 漸變角度,必須為45的整數倍。
android:type 漸變模式 默認是linear(線性漸變)radial(環形漸變)
android:centerX X坐標
android:centerY Y坐標
android:gradientRadius radial(環形漸變)時需指定半徑
-->

<padding />
<!-- 節點3: padding (定義內容離邊界的距離)
android:left 左部邊距
android:top 頂部邊距
android:right 右部邊距
android:bottom 底部邊距
-->

<size />
<!-- 節點4:size (大小)
android:width 指定寬度
android:height 指定高度
-->

<solid />
<!-- 節點5:solid (填充)
android:color 指定填充的顏色
-->

<stroke />
<!-- 節點6:stroke (描邊)
android:width 描邊的寬度
android:color 描邊的顏色
把描邊弄成虛線的形式"- - -":
android:dashWidth 表示'-'這樣一個橫線的寬度
android:dashGap 表示之間隔開的距離
-->

</shape></span>

『肆』 android 怎麼利用shape實現圓形用戶頭像

<?xml version="1.0" encoding="UTF-8"?><shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false" >
<solid android:color="@color/common_red" />
<padding
android:left="2dp"
android:top="1dp"
android:right="2dp"
android:bottom="1dp" />
<solid
android:color="@color/common_red" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
<size android:width="15dp"
android:height="15dp" /></shape>

『伍』 安卓在shape中怎樣設置背景顏色

使用XML的方式為背景添加漸變效果

1、在res/drawable文件夾里添加一個jbshape.xml文件,然後寫入如下代碼:

<?xmlversion="1.0"encoding="utf-8"?>
<shapexmlns:android="http://schemas.android.com/apk/res/android">

<gradient
android:angle="270"
android:centerColor="#00FFFF"
android:centerX="0.5"
android:centerY="0.5"
android:endColor="#666666"
android:startColor="#0099FF"/>

<padding
android:bottom="7dp"
android:left="7dp"
android:right="7dp"
android:top="7dp"/>

<cornersandroid:radius="4dp"/>

</shape>

說明:

(1)shape節點配置的是圖形的形式,主要包括方形、圓形等,上邊代碼為方形。

(2)gradient節點主要配置起點顏色、終點顏色及中間點的顏色、坐標、漸變效果(0,90,180從左到右漸變,270從上到下漸變)默認從左到右。

(3)corners節點配置四周圓角的半徑。

『陸』 android 里用shape畫圓,怎麼填充顏色

為你其中提供一種解決方案:
android;msg_new_counter"22"
android;
android;20dp"
android;>.com/apk/res/android"0dp" android;
android;
android;
android;utf-8".android;/://schemas;TextView
android; /:width="shape xmlns;top|center_horizontal".com/apk/res/android" target="_blank">http.0":background="3dp":text=":layout_height="bold" android;false"
android:textColor="ring"solid android;>
android;bg_have_msg".android://schemas;wrap_content":layout_width=";2":layout_marginTop="8sp":shape="stroke android; encoding="1;
android;3dp"
android;
<:id="
android;
<

2;#ffffff":useLevel="wrap_content"?xml version=":innerRadiusRatio=":textSize="#ff0000">@+id/1"
<
android;
android:color=":layout_marginLeft="#ff0000"
android:thicknessRatio=":color=".資源文件

<?>:textStyle="/ /:innerRadius=":padding=":android=">
<

在android studio的布局預覽里顯示正常(紅底白字的圓):thickness="
android布局文件

<1dp"

『柒』 安卓調試中如何更改圖片按鈕的形狀,改為圓形

shape
<shape>和<selector>在Android UI設計中經常用到。比如我們要自定義一個圓角Button,點擊Button有些效果的變化,就要用到<shape>和<selector>。
可以這樣說,<shape>和<selector>在美化控制項中的作用是至關重要。

在看這篇文章之前,可以看下這個小例子:鏤空按鈕的實現

1.Shape

簡介

作用:XML中定義的幾何形狀

位置:res/drawable/文件的名稱.xml

使用的方法:

Java代碼中:R.drawable.文件的名稱

XML中:Android:background="@drawable/文件的名稱"

屬性:

<shape> Android:shape=["rectangle" | "oval" | "line" | "ring"]

其中rectagle矩形,oval橢圓,line水平直線,ring環形

<shape>中子節點的常用屬性:

<gradient> 漸變

Android:startColor

起始顏色

Android:endColor

結束顏色

Android:angle

漸變角度,0從左到右,90表示從下到上,數值為45的整數倍,默認為0;

Android:type

漸變的樣式 liner線性漸變 radial環形漸變 sweep

<solid > 填充

Android:color

填充的顏色

<stroke >描邊

Android:width

描邊的寬度

Android:color

描邊的顏色

Android:dashWidth

表示'-'橫線的寬度

Android:dashGap

表示'-'橫線之間的距離

<corners >圓角

Android:radius

圓角的半徑 值越大角越圓

Android:topRightRadius

右上圓角半徑

Android:bottomLeftRadius

右下圓角角半徑

Android:topLeftRadius

左上圓角半徑

Android:bottomRightRadius

左下圓角半徑

閱讀全文

與androidshape實心圓相關的資料

熱點內容
怎麼查家裡電器耗電量app 瀏覽:502
原神一直顯示重新連接伺服器怎麼辦 瀏覽:808
一般用途軸流式壓縮機 瀏覽:922
沒學歷的怎麼學編程 瀏覽:893
華為的隱藏相冊無法加密 瀏覽:774
聯通套餐app怎麼設置 瀏覽:748
關於刪除鏈表的演算法描述 瀏覽:889
標准盤和壓縮盤的區別 瀏覽:42
銀行存款驗證碼JAVA編程 瀏覽:106
word轉pdf軟體免費版 瀏覽:137
公主連結安卓台服怎麼下載 瀏覽:548
注冊江蘇銀行app怎麼注冊 瀏覽:796
中興怎麼下載app視頻 瀏覽:673
伺服器審計是什麼 瀏覽:514
華為刪除的app怎麼徹底卸載 瀏覽:570
編程時調試快捷鍵 瀏覽:6
安卓手機玩亞服怎麼下載 瀏覽:339
思域壓縮機多少錢 瀏覽:695
程序員代碼合適嗎 瀏覽:288
復利計演算法律保護 瀏覽:741