【问题标题】:Buttons with fading shadow android带有渐变阴影android的按钮
【发布时间】:2017-07-25 07:23:16
【问题描述】:

我有一个带有三个按钮的 LoginActivity 屏幕,图片附在下面:

放大图片时,您会注意到用于 google 登录的按钮后面有一个黑色渐变阴影。我需要将此添加到 google 标志下方的其他 2 个按钮吗?

我的代码是:

LoginActivity.xml

<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="260dp"
android:layout_height="35dp"

android:layout_marginTop="41dp"
android:layout_below="@+id/app_name"
android:layout_centerHorizontal="true" />

<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="255dp"
android:layout_height="60dp"
android:textColor="#ffffff"
android:layout_marginTop="45dp"

android:layout_alignTop="@+id/sign_in_button"
android:layout_centerHorizontal="true" />

<Button
android:id="@+id/sign_in"
android:layout_width="260dp"
android:layout_height="35dp"
android:textSize="13dp"
android:text="Sign In"
android:textColor="@color/white"
android:textAllCaps="false"
android:background="@drawable/button_selector"
android:layout_below="@+id/login_button"
android:layout_alignLeft="@+id/sign_in_button"
android:layout_alignStart="@+id/sign_in_button"
android:layout_marginTop="33dp" />

button_selector drawable 用于最后一个按钮:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">

            <stroke android:width="4dp" android:color="#b9706f" />

        </shape>
    </item>

    <item
        android:left="0dp"
        android:right="0dp"
        android:top="0dp"
        android:bottom="2dp">
        <shape xmlns:android="http://schemas.android.com/apk/res/android">
            <stroke android:width="3dp" android:color="#ffffff" />
        </shape>
    </item>
</layer-list>

有什么方法可以实现吗?请建议我做错了什么,因为我尝试了 button_selector 的东西,但它并没有给我完美的阴影。

【问题讨论】:

    标签: android android-drawable android-button


    【解决方案1】:

    尝试添加阴影属性,例如:

    android:shadowColor="#000"
    android:shadowDx="0"
    android:shadowDy="0"
    android:shadowRadius="5"
    

    【讨论】:

    【解决方案2】:

    你为什么不试试AppCompactButton 它支持处理非物质(棒棒糖前)设备的阴影。它有一些默认高度。但是您始终可以覆盖此方法。不要忘记使用app 作为命名空间。

    【讨论】:

    • 查看文档here的链接
    猜你喜欢
    • 1970-01-01
    • 2015-06-05
    • 1970-01-01
    • 1970-01-01
    • 2012-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多