温馨提示×

android button属性能否设置阴影

小樊
81
2024-09-25 08:08:12
栏目: 编程语言

是的,Android Button属性可以设置阴影。你可以通过设置elevation属性来为按钮添加阴影效果。elevation属性表示按钮的高度(以dp为单位),增加elevation值会使按钮产生阴影效果。

在XML布局文件中设置elevation属性:

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Click me"
    android:elevation="4dp" />

在Java代码中设置elevation属性:

Button button = findViewById(R.id.button);
button.setElevation(4);

0