T
T
TikTak12362018-07-16 09:16:51
Android
TikTak1236, 2018-07-16 09:16:51

How to make custom buttons in android?

5b4c3813943e9407555345.png
Hello!
In my project I need to create buttons like in this picture, I managed to create them using layer-list, code example is below.

<?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="#793838" />
            <corners android:radius="10dp" />
        </shape>
    </item>

    <item android:bottom="3dp">
        <shape android:shape="rectangle">
            <corners android:radius="10dp" />
            <solid android:color="#4056b6" />
        </shape>
    </item>
</layer-list>

But the fact is that for each button you need to create a separate XML file, and I consider this bad code writing and decided to do it using custom buttons. How can I make custom buttons (from which class to inherit) or which solution is more efficient (so that you can reuse the code)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Chvarkov, 2018-07-16
@KuSu

Is this library right for you?

E
Eugene, 2018-07-16
@klim76

And what did you find custom here?
A simple button with text and an image.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question