Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使按钮没有填充物?_Android_Android Button - Fatal编程技术网

Android 如何使按钮没有填充物?

Android 如何使按钮没有填充物?,android,android-button,Android,Android Button,基本上,我希望白色按钮视图不具有灰色填充,同时保留按钮属性,以便可以看到单击。下面是我的xml代码,我已经尝试添加一个形状作为背景,但这会删除我想要的单击动画,我还尝试使用带有TouchListener的TextView来创建动画,但有人告诉我,由于可访问性,这不是一个好的做法: 您可以将minWidth、minHeight、insetTop、InsettBottom设置为零。 就这样 <Button android:layout_width="wrap

基本上,我希望白色按钮视图不具有灰色填充,同时保留按钮属性,以便可以看到单击。下面是我的xml代码,我已经尝试添加一个形状作为背景,但这会删除我想要的单击动画,我还尝试使用带有TouchListener的TextView来创建动画,但有人告诉我,由于可访问性,这不是一个好的做法:


您可以将minWidth、minHeight、insetTop、InsettBottom设置为零。 就这样

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/app_name"
        android:padding="0dp"
        android:minHeight="0dp"
        android:minWidth="0dp"
        android:insetTop="0dp"
        android:insetBottom="0dp" />

  • 如果使用了任何样式,请检查样式
  • 将宽度和高度标记为匹配约束

  • 您可以创建自定义绘图并将其用作按钮中的背景

    <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
    
        <solid android:color="#4CAF50"/>
    
    </shape>
    

    它保持不变告诉我们你做了什么显示你的xmlfirst@ebs237添加了xmluse
    android:insetTop=“0dp”android:insettbottom=“0dp”android:insettleft=“0dp”android:insetRight=“0dp”
    它应该可以解决problem@ebs237它保持不变,应该用代码很好地解释!我已经试过了,它可以工作,但是它丢失了一些按钮属性,比如点击动画,我想你必须使用材质按钮,请访问-
    <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
    
        <solid android:color="#4CAF50"/>
    
    </shape>
    
    android:background="@drawable/yourcustomview"