Why would I not be able to add margin to the end of this button?
<!--Buttons-->
<androidx.constraintlayout.widget.ConstraintLayout android:id="@ id/arqo_llButtons" android:layout_width="match_parent"
android:layout_height="98dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
android:background="@color/white" >
<!--Pay Button-->
<android.widget.Button android:id="@ id/arqo_btnQuickApplyPayment" style="@style/CustomButtonStyle.Success"
android:layout_width="200dp" android:layout_height="60dp" android:layout_marginEnd="16dp"
android:enabled="false" android:text="@string/button_pay" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<style name="CustomButtonStyle">
<item name="android:layout_height">55dp</item>
<item name="android:layout_width">332dp</item>
<item name="android:layout_margin">5dp</item>
<item name="android:textSize">18sp</item>
<item name="android:gravity">center</item>
<item name="android:paddingTop">5dp</item>
<item name="android:paddingBottom">5dp</item>
<item name="android:paddingEnd">10dp</item>
<item name="android:paddingStart">10dp</item>
<item name="android:clickable">true</item>
<item name="android:drawablePadding">5dp</item>
<item name="android:textColor">@color/border_button_text</item>
<item name="android:background">@drawable/button_border</item>
</style>
<style name="CustomButtonStyle.Success" parent="@style/CustomButtonStyle">
<item name="android:background">@drawable/button_success</item>
</style>
The button here just sits on the very right edge of the constraint layout...
CodePudding user response:
If you want to customize your button with a custom style, your custom style should inherit a button's style. Something like this :
<style name="CustomStyle" parent="Widget.MaterialComponents.Button">
<!-- Style your custom button here -->
</style>
For more info : Material Button theming
Material3 Button Theming
CodePudding user response:
Removing this line from the CustomButtonStyle in Styles.xml solved the issue:
<item name="android:layout_margin">5dp</item>