I'm new to programming on Android. I can't find this component in the material design documentation and I'd like to know how to do it.
CodePudding user response:
I've never seen it as a pre-built component, maybe someone can correct me if I'm wrong.
But replicating it would be fairly simple.
2 Buttons
and a ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
app:layout_constraintHorizontal_weight="6"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:id="@ id/sign_in_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right|center_vertical"
android:text="Sign In" />
<Button
app:layout_constraintHorizontal_weight="4"
app:layout_constraintLeft_toLeftOf="@ id/sign_in_button"
app:layout_constraintTop_toTopOf="@ id/sign_in_button"
app:layout_constraintBottom_toBottomOf="@ id/sign_in_button"
android:id="@ id/register_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Register" />
</androidx.constraintlayout.widget.ConstraintLayout >
You will have to tweak it for your use case but this should be like 90% of what you need. You may also have to create a custom button to get that more rounded shape. This is an older tutorial on how to customize buttons it should still be relevant. https://www.codebrainer.com/blog/13-designs-for-buttons-every-android-beginner-should-know
CodePudding user response:
Please go through this link. You will able to find how to customize the button as per your requirements. Here you can add your button background so that you can put your required design for your button. Try this and hope you find your solution