简体   繁体   English

在Android中创建自定义圆形按钮

[英]Creating a custom round button in android

Can anyone help me out here. 有人可以帮我从这里出去吗。 I am trying to create a small round button that would represent a lottery ball using a very simple self created XML class round_button.xml. 我正在尝试使用一个非常简单的自行创建的XML类round_button.xml创建一个小的圆形按钮,代表彩票球。 However I keep getting the error over and over even when Ive put the code through a w3schools validator that " Error parsing XML: junk after document element." 但是,即使我已经通过w3schools验证程序将代码放入“错误地解析XML:文档元素后的垃圾”,我仍然不断出错。 I cannot see what the issue is here and maybe I am missing something very clear, I dont know. 我看不到这里是什么问题,也许我不知道很清楚。 Could anyone please help me out. 谁能帮我一下。 Here is the code: 这是代码:

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

You are just missing a bit of concept of closing the tags. 您只是缺少一些关闭标签的概念。 You have extra / over android:shape="oval" /> . 你有额外的/android:shape="oval" /> You are already closing the tag at the end with </shape> so no need to use /> . 您已经使用</shape>结束了标签的结尾,因此无需使用/>

Secondly you haven't ended <solid tag with /> . 其次,你还没有结束<solid与标签/> So try something like: 因此,尝试类似:

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

You messed up tags. 您弄乱了标签。 You have closed shape before end and not closed solid tag. 您在结束之前已封闭形状,但未封闭实体标签。 Try this one. 试试这个。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM