为什么我不能够创造特定的角落一轮边界? [英] Why i am not able to create the round border for specific corner?

查看:122
本文介绍了为什么我不能够创造特定的角落一轮边界?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid XML布局我使用borderframe.xml作为后台应用的边界。

In My android xml layout i am applying the border by using the borderframe.xml as a background.

borderframe.xml文件看起来如下:

borderframe.xml file is looks like below:

    <?xml version="1.0" encoding="UTF-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke 
        android:width="1dip" 
        android:color="#ffffff"/>
    <solid 
        android:color="#95865F"/>
    <corners 
        android:radius="10px"/>

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

现在,虽然是一个机器人:半径=10px的,那么它​​是工作,但同时我要给圆形特定的角落才把它不工作。 有没有在日志中的猫任何埃罗消息,但我发现的错误在Eclipse这样的:

Now, While there is a android:radius="10px" then it is works but while i am going to give round shape to specific corner only then it not works. There is no any erro message in log cat but i found error in eclipse like:

    The graphics preview in the layout editor may not be accurate:
* Different corner sizes are not supported in Path.addRoundRect.

即使是在XML文件中没有填充,然后还我不能够看到任何边界。

Even if there is no padding in that xml file then also i am not able to see any border.

现在,我应该我必须做的呢? 和最新它的sollution如果我想创建圆角边框仅topLeftcorner和bottomLeftCorner。 ? 谢谢你。

Now, what should i have to do for it ? and whats the sollution of it if i want to create the rounded border for only topLeftcorner and bottomLeftCorner. ? Thanks.

推荐答案

你必须要做到这一点,假设你只想要一个圆形的左上角:

You'll have to do that, assuming you only want a rounded top left corner:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
  <corners
      android:radius="20sp"
      android:topRightRadius="0dp"
      android:bottomRightRadius="0dp"
      android:bottomLeftRadius="0dp" />
  <gradient
      android:startColor="@color/logo_blue"
      android:endColor="@color/blue"
      android:angle="0"/>
</shape>

说明:每一个角落,必须在开始阶段,提供一个拐角半径大于1,否则无边角圆润。如果你想具体的角落,不进行四舍五入,一个解决办法是使用安卓半径来设置默认圆角半径大于1,但随后将覆盖每一个角落你真的想要,你不希望圆角的价值,提供零(0dp)。 []

Explanation: Every corner must (initially) be provided a corner radius greater than 1, or else no corners are rounded. If you want specific corners to not be rounded, a work-around is to use android:radius to set a default corner radius greater than 1, but then override each and every corner with the values you really want, providing zero ("0dp") where you don't want rounded corners. [source]

因此​​,你需要确定你的绘制如下:

As a consequence, you need to define your drawable as:

<?xml version="1.0" encoding="UTF-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke 
        android:width="1dip" 
        android:color="#ffffff"/>
    <solid 
        android:color="#95865F"/>
    <corners 
       android:radius="10px"
      android:topRightRadius="0dp"
      android:bottomRightRadius="0dp" />

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

更新

形状绘制资源的Andr​​oid文档

安卓半径   尺寸。半径的各个角落,为维度   值或尺寸的资源。这是每一个角落的覆盖   以下属性。

android:radius Dimension. The radius for all corners, as a dimension value or dimension resource. This is overridden for each corner by the following attributes.

覆盖的关键字搜索您的问题...

overridden is the keyword for your problem…

这篇关于为什么我不能够创造特定的角落一轮边界?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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