如何在 Android XML 可绘制文件中定义圆形? [英] How to define a circle shape in an Android XML drawable file?

查看:64
本文介绍了如何在 Android XML 可绘制文件中定义圆形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在查找 XML for Android 中形状定义的文档时遇到了一些问题.我想在 XML 文件中定义一个用纯色填充的简单圆圈,以将其包含在我的布局文件中.

I have some problems finding the documentation of the definitions of shapes in XML for Android. I would like to define a simple circle filled with a solid color in an XML File to include it into my layout files.

遗憾的是,android.com 上的文档并未涵盖 Shape 类的 XML 属性.我想我应该使用 ArcShape 来画一个圆,但有没有说明如何设置圆弧所需的大小、颜色或角度.

Sadly the Documentation on android.com does not cover the XML attributes of the Shape classes. I think I should use an ArcShape to draw a circle but there is no explanation on how to set the size, the color, or the angle needed to make a circle out of an Arc.

推荐答案

这是一个简单的圆作为 Android 中的可绘制对象.

This is a simple circle as a drawable in Android.

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

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

   <size 
       android:width="120dp"
        android:height="120dp"/>
</shape>

这篇关于如何在 Android XML 可绘制文件中定义圆形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆