安卓 : The rounded corners work different in different Android version

标签 android android-layout

我对 corners 标签有疑问。

这是我的形状文件。

<stroke
    android:width="1dp"
    android:color="#ff999999" />

<size android:height="40dp" />

<gradient
    android:angle="90"
    android:centerColor="#f5f5f5"
    android:endColor="#fcfcfc"
    android:startColor="#efefef"
    android:type="linear" />

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

但是当我将它设置为 View 的背景时。它在 Android 2.2 和 Android 4.0.3 中显示不同的形状。 当它在 Android 4.0.3 上运行时:running on Android 4.0.3 在 Android 2.2 上:Running on Android 2.2

请参阅“公告”按钮。 你知道为什么吗 ?我该如何解决? 请帮我 ! 抱歉,我的英语不是很好。

最佳答案

这是 SDK 的 API 12 之前版本中的一个错误,其中左下角和右下角的半径颠倒了。您可以做的(this link 中有更多信息)是创建一个 res/drawable-v12 文件夹,然后将这些可绘制对象复制到其中,半径反转(即左下角半径变为右下角半径,反之亦然),这些可绘制对象将自动为 API 12 以上的设备选择。

关于安卓 : The rounded corners work different in different Android version,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11692129/

相关文章:

android edittext 与 alertdialog

java - 在不使用 "Intent.ACTION_CALL"的情况下在 Android 中运行 USSD 代码

android - FILL_PARENT 和 MATCH_PARENT

android - 如何更改工具栏导航和溢出菜单图标(appcompat v7)?

android - 扩展 FrameLayout, subview 将不再显示

android - 奇怪的应用程序内存管理

Android:如何合并两个形状的路径并去除重叠?

database - 我可以在/sdcard 上下载 SQLite db 并从我的 Android 应用程序访问它吗?

android - 我可以使工具栏的颜色渐变吗?

android - 将 View 添加到 fragment 内的布局