Hey I am working on an application Where I have two Buttons "Call Now" and "Chat Now". Generally We only show one button "Chat Now". If User Provide check "show call button" option then we will show both buttons. Otherwise only Chat Now Button will show. But the problem is in design if user enable call button then it will look like this
like this.
but the problem is that when i show the both it looks good but when i show only the Chat Now button it look weird while it should be.
like this
XML CODE
<LinearLayout
android:id="@+id/callNowLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
android:layout_marginTop="300dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<Button
android:id="@+id/callNow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:backgroundTint="#FF5722"
android:padding="10dp"
android:text="Call Now"
android:textAllCaps="false"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/chatNow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:padding="10dp"
android:text="Chat Now"
android:backgroundTint="#FF5722"
android:textAllCaps="false"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/callNow" />
</LinearLayout>
2
Answers
Try this
Try this XML and use if else conditions as per your code.
As per conditions use visibility programmatically.