1

I'm creating my first application in android studio. I have a question. Is there something like class in css. For example

android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:background="#fffff0"
            android:text="@string/button_1"
            android:textColor="@color/black"
            android:textSize="30sp">

I have about 10 buttons with the same layout, background etc. Only diffrence is string and id. Can i just make a class which contains all of stuff which is common?

1 Answers1

0

hmmm if you mean to sum up all the xml code you can. You can create a new custom style for your button and use this style button in all your different id buttons. you can have a look in this question

create this style for Example

<style name="AppTheme.Button" parent="Widget.AppCompat.Button.Colored">
    <item name="colorButtonNormal">@color/Red</item>
    <item name="android:textColor">@color/White</item>
    ...
</style>

and then go to your button and apply that style

NickNterm
  • 94
  • 4