0

This is an example of the buttons that I need to create

This

I want to create a button with the bottom border, I was able to create a button using layer-list, but now for each button I have to create a separate layer-list. Are there any ways to create one template and reuse it?

This is the code to create a button with a layer-list

background_button.xml

<?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>
L_J
  • 2,351
  • 10
  • 23
  • 28
TikTak
  • 713
  • 1
  • 11
  • 23
  • 1
    You can use the same drawable for each button. Right? – DAS Jul 09 '18 at 13:06
  • this set every button background and text set as center and white color. –  Jul 09 '18 at 13:09
  • @SibinDavis I can not, I need to create a new drawable each time, because in each drawable I set the color background and bottom border, because of this I think it can create a custom button programmatically. What say? – TikTak Jul 16 '18 at 06:41
  • @AndroidTeam Oh sure. Can you give advice on how I can implement this more elegantly? – TikTak Jul 16 '18 at 06:48

2 Answers2

0

Use below link to create custom buttons for android. http://angrytools.com/android/button/

Vikram Kaldoke
  • 150
  • 1
  • 8
  • A cool idea, but now for each button you have to create a separate XML file. Is there a more elegant solution? – TikTak Jul 16 '18 at 06:52
0

You must do it programmatically, once you have created the layout of a button you can reuse it several times.. here one example but you can find more! Creating multiple buttons programmatically: Android

Giulio Pettenuzzo
  • 786
  • 1
  • 5
  • 20