android - android中的背景阴影

标签 android kotlin user-experience dropshadow

Is there any way in Android that applies drop shadow as shown in Figma or XD Tool ?


enter image description here
我有一个 figma 设计,我一直在创建这个下降效果我已经尝试使用 selectorlayer-list有什么方法可以申请 x , y 和模糊 效果以及不透明度的阴影颜色。
以上属性仅适用于 编辑文本 但不适用于 文本输入布局
我在 Figma 中的 View 属性如下。
enter image description here

最佳答案

新的和最好的方法 (我希望这是你所需要的)
enter image description here

 <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/passwordTV"
        style="@style/Widget.App.TextInputLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@drawable/text_input_selector"
        android:backgroundTint="#0B102C"
        android:outlineAmbientShadowColor="#1EB0D5"
        android:outlineSpotShadowColor="#1EB0D5"
        android:textColorHint="#4A5478"
        android:translationZ="@dimen/_10sdp"
        app:endIconDrawable="@drawable/ic_show_password"
        app:endIconMode="password_toggle"
        app:hintTextColor="#4A5478">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/passwordEt"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            android:drawableStart="@drawable/ic_lock"
            android:drawablePadding="7dp"
            android:hint="  Password"
            android:inputType="textPassword"
            android:textColor="@color/white"
            android:textColorHint="#CAD5F4"
            android:textSize="12dp" />

    </com.google.android.material.textfield.TextInputLayout>
  • 您只需在 中创建一个 text_input_selector可绘制
     <selector xmlns:android="http://schemas.android.com/apk/res/android">
         <item
             android:state_focused="true"
             android:drawable="@drawable/background_glow"/>
     </selector>
    
    text_input_selector.xml
  • 现在在 中创建背景发光形状可绘制
  • <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <solid android:color="#0C263E"/>
        <corners android:radius="7dp"/>
    </shape>
    
    background_glow.xml

    关于android - android中的背景阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72644805/

    相关文章:

    android - 在android的应用程序菜单中隐藏一个应用程序

    kotlin - 如何在 Visual Studio 代码中运行 kotlin

    android - Realm Kotlin - 删除 Realm 对象

    javascript - 当浏览器最小化时引起用户的注意(跨浏览器桌面通知?)

    css - 在响应式 UI 中悬停时停止移动其他 div

    android - startChooser() 方法和 startActivity() 之间的区别

    java - android中cardview中的Clickable false无法工作

    java - 没有通知的 Android 前台服务 - 如何?

    format - kotlin 的字符串模板使用哪种语言环境?

    web - 如何填充虚假的浏览器历史记录?