当前位置: 首页 > 知识库问答 >
问题:

AndroidL凸起普通按钮

谈禄
2023-03-14

我一直在寻找一种方法来获得一个“凸起”圆角矩形按钮,而不是完全自己使用背景和自定义视图。我想要这样的纽扣:

我以为这样就可以了:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MyActivity">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Enter the Danger Zone"
        android:id="@+id/btn"
        android:elevation="8dp" <!-- Here -->
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="16dp"/>

</RelativeLayout>

但这没什么用。按钮看起来一样。WTF?

是的,我用的是最新的SDK等等。

编辑:所以我添加了一个translationz。现在,一个阴影在活动打开时出现,但在动画完成时消失。???

共有1个答案

慕乐池
2023-03-14

尝试添加状态列表动画器:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:state_enabled="true"
    android:state_pressed="true">
    <set>
        <objectAnimator
            android:duration="@android:integer/config_shortAnimTime"
            android:propertyName="translationZ"
            android:valueTo="8dp"
            android:valueType="floatType" />
    </set>
</item>
<item>
    <set>
        <objectAnimator
            android:duration="@android:integer/config_shortAnimTime"
            android:propertyName="translationZ"
            android:valueTo="2dp"
            android:valueType="floatType" />
    </set>
</item>
</selector>
 类似资料:
  • 把 input 元素的 type 属性设置为“button”,可以创建普通按钮。按钮上显示的文本是value 属性的值,如果没有提供 value 属性,则只创建一个空按钮。如: <input type="button" value="立即购买"> 上述按钮的运行结果如图 3‑33 所示: 图3-33 普通按钮 默认情况下,在普通按钮上点击,是没有任何反应的。因此,需要为普通按钮注册事件,并手动编

  • 重复执行一系列命令:可以指定表示重复次数的数字或直到遇到 break。 Loop [, Count] 参数 Count 执行循环体 (重复) 的次数. 如果省略, Loop 会无期限继续, 直到遇到 break 或 return. 如果 Count 是一个变量引用例如 %ItemCount%, 每当此变量为空或包含小于 1 的数字时, 循环会被完全跳过. 由于必须支持 文件模式循环, Count

  • null 你有什么推荐?另外,当我选择其中一个选项时,configure project是否可以将angular源文件导出到可部署的JAR文件中?谢谢你的忠告。

  • Wiki ▸ [[API Reference]] ▸ [[Geometry]] ▸ Hull Geom # d3.geom.hull() Create a new hull layout with the default x- and y-accessors. # hull(vertices) Returns the convex hull for the specified vertices a

  • 本文向大家介绍Fortran 普通块,包括了Fortran 普通块的使用技巧和注意事项,需要的朋友参考一下 示例 在Fortran的早期形式中,用于创建从子例程和函数可见的全局变量存储的唯一机制是使用COMMON块机制。这允许变量序列成为名称并共享。 除了已命名的公共块之外,还可能有一个空白(未命名)的公共块。 可以声明一个空白的公共块,例如 而命名块variables可以像 作为一个完整的示例,