2011-10-26 97 views
2

我想创建一个圆角右下角右上方角落的自定义按钮。搞砸圆角

不过,我得到左下方右上方圆润,而不是,虽然我的实现似乎是确定。

我在做什么错?存储在文件夹中抽拉

我使用以下形状的定义:

button_shape.xml

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

    <solid android:color="#F66622"/> 
    <padding 
    android:left="5dip" 
    android:top="5dip" 
    android:right="5dip" 
    android:bottom="5dip" 
    /> 
    <corners 
    android:radius="20dip" 
    android:bottomLeftRadius="0dip" 
    android:topLeftRadius="0dip" 
    /> 
</shape> 

和布局文件是这样的:

main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/bg" 
    > 
    <Button 
     android:id="@+id/btnFoo" 
     android:text="@string/btn_foo_title" 
     android:background="@drawable/button_shape" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="5dip" 
     android:layout_centerInParent="true" 
     android:textSize="26sp" 
    /> 
</RelativeLayout> 

这是结果:

messed corners http://img715.imageshack.us/img715/5954/corners.png

我也试图在button_shape文件

... 
<corners 
    android:bottomLeftRadius="0dip" 
    android:topLeftRadius="0dip" 
    android:bottomRightRadius="20dip" 
    android:topRightRadius="20dip" 
/> 
... 

单独定义每个角半径...同样的结果。

这种功能有可能在Android SDK中出现某种程度的混乱吗?

+0

我怀疑它的功能搞砸了!做项目 - >清洁,看看它是否能解决问题。 – Raunak

+0

我试过了,根本没有帮助。 – Tomas

回答

2

愚蠢的问题,但你有没有尝试bottomingLeft,看看它是否围绕右下角?我知道这不是一个真正的解决方案,但解决方法也很好。如果它看起来像你想要的那样,那么你如何实现它并不重要。

+0

当我将它更改为<角android:radius =“20dip”** android:bottomRightRadius =“0dip”** android:topLeftRadius =“0dip”/>,结果就是我所期望的。但是,这种解决方法对我来说并不令人满意:-) – Tomas

+1

如果您为自我满意编码,那么我不确定要告诉您什么。有机会,这是一个没有人发现的bug,因为之前没有人在四个角落之前舍弃或者没有人关心该错误足以提交它。但是,如果您正在编写一个功能正常的应用程序,那么解决方法并不完美,但是一个有效的应用程序本身就足以让您满意。至少,如果这是您不使用它的原因,我的回答值得评分:D – Jin