繁体   English   中英

android:topLeftRadius覆盖其他角落

[英]android:topLeftRadius overriding other corners

解决方案:好吧,这是我的模拟器和蚀布局编辑器。 在真正的电话上,它可以正常工作:(

题:

角落的android:topLeftRadius会覆盖topRight,bottomRight和bottomLeft。

因此,当我要对右侧进行圆角处理时,左侧应平方,但两侧均应平方。

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

<solid android:color="#F000" />

<stroke
    android:width="1px"
    android:color="#BB000000" />

<padding
    android:bottom="7dp"
    android:left="10dp"
    android:right="10dp"
    android:top="7dp" />

<corners
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="10dp"
    android:topLeftRadius="0dp"
    android:topRightRadius="10dp" />

<gradient
    android:angle="90"
    android:centerColor="#00004C"
    android:endColor="#000099"
    android:startColor="#000000"
    android:type="linear" />

</shape>

我只是在按钮的xml中调用它。

android:background =“ @ drawable / button_layout”

您忘记了在属性周围需要一个<shape> 该代码对我有用:

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

  <stroke
     android:width="1px"
     android:color="#BB000000" />

  <padding
     android:bottom="7dp"
     android:left="10dp"
     android:right="10dp"
     android:top="7dp" />

  <corners
     android:bottomLeftRadius="0dp"
     android:bottomRightRadius="10dp"
     android:topLeftRadius="0dp"
     android:topRightRadius="10dp" />

  <gradient
     android:angle="90"
     android:centerColor="#00004C"
     android:endColor="#000099"
     android:startColor="#000000"
    android:type="linear" />

</shape>

这可能与3.0之前的Android版本中的错误有关(请参阅https://code.google.com/p/android/issues/detail?id=9161

您可以通过为不同的api版本使用单独的可绘制文件夹来解决此问题。

另请参见Android转角半径中的某些问题

暂无
暂无

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

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