简体   繁体   English

可绘制的自定义按钮,例如facebook

[英]Custom button with drawable, like facebook

I have been all morning trying to do an custom shape like as facebook button like this: 我整个上午都在尝试做一个自定义形状,例如facebook按钮,如下所示:

Facebook登录按钮

But I'm trying to do it customizable, so in the future I could change the icon for example, but I'm going crazy. 但是我正在尝试使其可自定义,因此将来我可以更改图标,例如,但是我疯了。

How I can make a button like this? 我如何制作这样的按钮? Only the right part must be pressed, the left with the icon must be static although it will be pressed. 尽管必须按下,但只有右边部分必须按下,带有图标的左边必须是静态的。

I have this for the left side: 我在左边有这个:

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

            <corners
                android:topLeftRadius="4dp"
                android:topRightRadius="4dp"/>
            <size
                android:height="@dimen/bt_icon_size"
                android:width="@dimen/bt_icon_size"
            />
        </shape>
    </item>
    <item
        android:left="10dp">
        <shape android:shape="rectangle">
            <solid
                android:color="@color/gecas_blue"/>
            <size
                android:height="@dimen/bt_icon_size"
                android:width="@dimen/bt_icon_size"
                />
        </shape>
    </item>
    <item android:drawable="@android:drawable/ic_input_add">
        <size
            android:height="@dimen/bt_icon_size"
            android:width="@dimen/bt_icon_size"
            />
    </item>
</layer-list>

And this for the right, but I know how to continue: 这是正确的,但我知道如何继续:

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

            <corners
                android:topLeftRadius="4dp"
                android:topRightRadius="4dp"/>
        </shape>
    </item>
    <item
        android:right="10dp">
        <shape android:shape="rectangle">
            <solid
                android:color="@color/gecas_blue"/>
        </shape>
    </item>
</layer-list>

This is the most similar library that I've found. 这是我发现的最相似的库。

Flat Buttons 平面按钮

尝试https://github.com/medyo/fancybuttons,它几乎符合您的尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM