Is it possible to create a button by passing parameters in XML ? doing it that way ?
<Button
button:typeParameter="primary"
button:size="md"/>
And after passing these 2 parameters the button is created as it should be, is it possible to do this?
I already have a button on which I created new attributes, now I want to know if it is possible to pass parameters and this button be called, without the need for the developer to have to code all these lines.
<customButton
android:fontFamily="@font/mondrian_family_font"
app:fontFamily="@font/mondrian_family_font"
android:id="@+id/mdnButtonPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:text="Button primary"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:textColor="@color/color_neutral_lightest"
android:layout_marginTop="10dp"
android:textSize="@dimen/font_size_XXS"
mdnbutton:radius="@dimen/border_radius_pill"
mdnbutton:defaultColor="@color/color_brand_primary_medium"
mdnbutton:focusColor="@color/color_brand_primary_darkest"
style="?android:attr/borderlessButtonStyle"/>
It is possible that he will use these attributes after he installs my library. Now I want that when the developer is going to create his layout, instead of creating a button from scratch, he just passes parameters in the XML and the button is rendered.
Viewattributes. However, you'd have to create a customButtonsubclass, and you wouldn't be able to specify only those two custom attributes, there. You'll need at least the standardandroid:layout_widthandandroid:layout_heightattributes set, as well.