什么是错的圆角半径的Andr​​oid [英] Something's wrong in Corner radius Android

查看:110
本文介绍了什么是错的圆角半径的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做我自己的搜索视图为Android 2.3。

I'm making my own search view for Android 2.3.

我有。

  • 的LinearLayout (水平)
  • AutoCompleteTextView
  • 的ImageButton
  • LinearLayout (Horizontal)
  • AutoCompleteTextView
  • ImageButton

我添加的按钮和 AutoCompleteTextView 的LinearLayout

我想提出一个圆角半径在我自己的控制如下所示的图像。

I want to put a corner radius in my own control like the image shown below.

我设置可绘制到的ImageButton

I set this drawable to ImageButton

<selector xmlns:android="http://schemas.android.com/apk/res/android" >
 <item android:state_pressed="true" >
    <shape>
        <solid
            android:color="#27AFE0" />
        <stroke
            android:width="0.5dp"
            android:color="#000000" />
        <corners
            android:topRightRadius="10dp" android:bottomRightRadius="10dp"
android:topLeftRadius="0.1dp"
            android:bottomLeftRadius="0.1dp" />
        <padding
            android:left="10dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp" />
    </shape>
</item>
<item>
    <shape>
        <solid android:color="#D3DBDE"/>
        <stroke
            android:width="0.5dp"
            android:color="#000000" />
        <corners
            android:topRightRadius="10dp" android:bottomRightRadius="10dp"
android:topLeftRadius="0.1dp"
            android:bottomLeftRadius="0.1dp" />
        <padding
            android:left="10dp"
            android:top="10dp"
            android:right="10dp"
            android:bottom="10dp" />
    </shape>
</item>

绘制到AutoCompleteText

drawable to AutoCompleteText

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <solid android:color="#D3DBDE"/>
        <stroke android:width="0.5dp" android:color="#000000"/>
        <corners android:topLeftRadius="10dp"
            android:bottomLeftRadius="10dp"
            android:topRightRadius="0.1dp"
            android:bottomRightRadius="0.1dp"/>
    </shape>
</item>

但是当我运行这是Android 2.3,这是输出(模拟器和真实设备)

But when I run this in android 2.3 this is the output (Emulator and Real Device)

如果我在的Andr​​oid 4.0也运行。它工作正常。

If I run also in Android 4.0 . It works fine.

问题是,什么是错误的,我code?或者有错误,在Android 2.3的?

Question is, what's wrong in my code? Or There's bug in Android 2.3?

推荐答案

好了,所以这里是这打勾我送行,以及这笔交易。有两件事情与此有关。

Ok so here is the deal this ticked me off as well. There are 2 things with this.

在你的ImageButton选择,你似乎在每个角落标签两次复制属性的右下角。

In your ImageButton Selector, you seemed to copy the attributes for the right corners twice in each corner tag.

二是在Android的一个错误,直到3.0版。当单独指定的角落,左下角和右上角得到翻转。

The second is a bug in android up until version 3.0. When specifying the corners separately, the bottom left and right corners get flipped.

<一个href="http://$c$c.google.com/p/android/issues/detail?id=9161">http://$c$c.google.com/p/android/issues/detail?id=9161

我已经提取的价值观出梦诗,把他们在两个不同的文件,

I have extracted the values out to dimens and put them in two different files,

RES /价值/ corners.xml - 以扭转的东西

res/values/corners.xml - with the reversed stuff

RES /值-V12 / corners.xml - 在他们的理智值

res/values-v12/corners.xml - with the sane values in them.

这篇关于什么是错的圆角半径的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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