Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.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_Properties_Android Button - Fatal编程技术网

Android 有关按钮的一些问题…(标高、单击效果等)

Android 有关按钮的一些问题…(标高、单击效果等),android,properties,android-button,Android,Properties,Android Button,xml代码和图片就是我制作的UI 我想继续这个设计 我引用了这个链接。 Q1。在这种情况下,您如何赋予按钮点击效果? 我想给按钮一个提升效果 通常,在使用“高程”属性时,它不适用 所以我使用了android:stateListAnimator=“@null”属性。 很好 但是,当我单击时,按钮单击效果不会出现 原因是stateListAnimator属性。当我删除此项时,会出现按钮单击效果 但是,如果删除此项,则无法调整高程属性的深度 所以,也许我需要这个属性来进行elavation Q2。

xml代码和图片就是我制作的UI

我想继续这个设计

我引用了这个链接。

Q1。在这种情况下,您如何赋予按钮点击效果?

我想给
按钮
一个
提升
效果

通常,在使用“高程”属性时,它不适用

所以我使用了
android:stateListAnimator=“@null”
属性。 很好

但是,当我单击时,按钮单击效果不会出现

原因是
stateListAnimator
属性。当我删除此项时,会出现按钮单击效果

但是,如果删除此项,
则无法调整高程属性的深度

所以,也许我需要这个属性来进行elavation


Q2。选择按钮颜色时,
background
backgroundTint
之间有什么区别?

当我第一次设置按钮的颜色时,我使用了
background=“@color/white”
属性

但是颜色没有改变

在该链接中,显然我们使用
background
属性作为按钮的颜色

我使用按钮背景属性的情况是当我使用
background=“?android:selectableItemBackground”
background=“#00ff0000”

除了按钮上的文本外,这两个属性使其完全透明


Q3。为什么
background=“@color/white
”不适用?


关于Q2,我很好奇为什么在使用
background
属性指定颜色时,颜色不会改变。

首先,这不是一次问多个问题的最佳方式!对于您的问题,这里有一个提示:

  • 使用按钮而不是普通按钮:

  • 第二个问题请访问


请不要一次问多个问题,这对未来的人们没有帮助。坚持一次只问一个问题,否则你的问题将被关闭,然后你也找不到答案。对不起:(谢谢你:)
<Button
    android:id="@+id/delete_set"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:backgroundTint="@color/white"
    android:drawableLeft="@drawable/ic_remove_routine"
    android:elevation="4dp"
    android:translationZ="3dp"
    android:stateListAnimator="@null"
    android:text="Remove Set"
    android:textSize="12dp"
    android:textColor="@color/orgin_text_color"
    android:clickable="true"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="1dp"
    android:layout_marginRight="1dp"
    app:layout_constraintHorizontal_weight="1"/>
<Button
    android:id="@+id/add_set"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:backgroundTint="@color/white"
    android:drawableLeft="@drawable/ic_add_routine"
    android:text="ADD SET"
    android:textSize="12dp"
    android:elevation="4dp"
    android:translationZ="3dp"
    android:stateListAnimator="@null"
    android:textColor="@color/orgin_text_color"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="1dp"
    android:layout_marginRight="1dp"
    app:layout_constraintHorizontal_weight="1"/>