android - Buttonstyle - 尺寸类型不允许

标签 android android-xml android-button

我设计了一个按钮,如下所示,但是收到了一些错误消息。

    android:background="@drawable/buttonshape"
    android:shadowColor="#A8A8A8"
    android:shadowDx="0dp"
    android:shadowDy="0dp"
    android:shadowRadius="5dp"

Dimension types not allowed (at 'shadowDy' with value '0dp'). Dimension types not allowed (at 'shadowRadius' with value '5dp'). Dimension types not allowed (at 'shadowDx' with value '0dp').

buttonshape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <corners
        android:radius="14dp"
        />
    <gradient
        android:angle="45"
        android:centerX="35%"
        android:centerColor="#198CFF"
        android:startColor="#449DEF"
        android:endColor="#2F6699"
        android:type="linear"
        />
    <padding
        android:left="0dp"
        android:top="0dp"
        android:right="0dp"
        android:bottom="0dp"
        />
    <stroke
        android:width="1dp"
        android:color="#878787"
        />
</shape> 

最佳答案

只是不要使用单位,例如:

   android:shadowDx="2"
   android:shadowDy="2"
   android:shadowRadius="5"
   android:shadowColor="#A8A8A8"

关于android - Buttonstyle - 尺寸类型不允许,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36351939/

相关文章:

android - AppBarLayout 中的工具栏是可滚动的,尽管 RecyclerView 没有足够的内容可以滚动

Android点击时更改背景颜色

android - 为什么按钮没有 Material 触摸反馈?

android - 使android底部按钮栏仅在我滚动到页面底部时出现

java - 使用 SelectionTracker 删除 RecycleView 中的项目

java - 使用抽象类作为 RecyclerView Adapter 的基础?

android - AS3 fl.controls.TextInput 和移动平台

android - 获取颜色资源作为字符串

android - 什么是android :includeFontPadding for?

android - 如何在android中收听双击 View ?