Я показываю закусочную в двух разных видах деятельности. Код для закусочной -
Snackbar snackbar = Snackbar.make(activity.findViewById(android.R.id.content), "Do you want to log out ?", Snackbar.LENGTH_LONG);
snackbar.setActionTextColor(Color.WHITE);
View view = snackbar.getView();
TextView textView = view.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.WHITE);
snackbar.setAction("Log out", v1 -> {
snackbar.setText("Please wait");
//call log out api
});
snackbar.show();
Когда я звоню с первого занятия, это выглядит так.
https://ibb.co/56QfCW8
Когда я звоню из-за своей секундной активности, это выглядит так.
https://ibb.co/0MZ8LcQ
Единственное отличие состоит в том, что первое действие имеет в качестве корневого размещения разметку кадров, а во втором - макет движения.
Стили одинаковы в обоих видах деятельности.
Первое действие xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black">
<com.joooonho.SelectableRoundedImageView
android:id="@+id/bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/loginn"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:sriv_border_color="@color/black"
app:sriv_border_width="2dip"
app:sriv_left_bottom_corner_radius="0dip"
app:sriv_left_top_corner_radius="16dip"
app:sriv_right_bottom_corner_radius="0dip"
app:sriv_right_top_corner_radius="16dip" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:id="@+id/constraint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:fontFamily="sans-serif-light"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="40sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:text="@string/full_name"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
<android.support.design.widget.TextInputLayout
android:id="@+id/til_email"
style="@style/TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:hint="username"
android:textColorHint="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3">
<android.support.design.widget.TextInputEditText
android:id="@+id/tie_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_name"
android:drawablePadding="10dp"
android:inputType="textEmailAddress"
android:textColor="@color/white"
android:textCursorDrawable="@drawable/cursor" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/til_password"
style="@style/TextInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="password"
app:passwordToggleTint="@color/white"
android:textColorHint="@color/white"
app:layout_constraintEnd_toEndOf="@+id/til_email"
app:layout_constraintStart_toStartOf="@+id/til_email"
app:layout_constraintTop_toBottomOf="@+id/til_email"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="@+id/tie_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_key"
android:drawableLeft="@drawable/ic_key"
android:drawablePadding="10dp"
android:inputType="textPassword"
android:textColor="@color/white"
android:textCursorDrawable="@drawable/cursor" />
</android.support.design.widget.TextInputLayout>
<br.com.simplepass.loading_button_lib.customViews.CircularProgressButton
android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="32dp"
android:background="@drawable/shape_default"
android:onClick="login"
android:padding="16dp"
android:text="Login"
android:textColor="@color/white"
app:finalCornerAngle="50dp"
app:initialCornerAngle="50dp"
app:layout_constraintEnd_toEndOf="@+id/til_password"
app:layout_constraintStart_toStartOf="@+id/til_password"
app:layout_constraintTop_toBottomOf="@+id/til_password"
app:spinning_bar_color="#fff"
app:spinning_bar_padding="6dp"
app:spinning_bar_width="4dp" />
<Space
android:layout_width="match_parent"
android:layout_height="400dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/button" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
</FrameLayout>
Второе задание xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/motionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true"
app:layoutDescription="@xml/scene_01"
tools:context=".MainActivity">
<android.support.constraint.ConstraintLayout
android:id="@+id/materialCardView2"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintVertical_weight="2.5"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView4">
<android.support.design.card.MaterialCardView
android:id="@+id/materialCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="4dp"
app:cardElevation="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:strokeColor="@color/colorPrimary"
app:strokeWidth="2dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="Phone Number"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text=":"
app:layout_constraintBottom_toBottomOf="@+id/num"
app:layout_constraintStart_toEndOf="@+id/num"
app:layout_constraintTop_toTopOf="@+id/num"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Email ID"
app:layout_constraintEnd_toEndOf="@+id/num"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/num"
app:layout_constraintTop_toBottomOf="@+id/num" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
app:layout_constraintEnd_toEndOf="@+id/textView4"
app:layout_constraintStart_toStartOf="@+id/textView4"
app:layout_constraintTop_toTopOf="@+id/textView5" />
<TextView
android:id="@+id/textView7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:text="Batch"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/textView5"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/textView5"
app:layout_constraintTop_toBottomOf="@+id/textView5" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=":"
app:layout_constraintEnd_toEndOf="@+id/textView6"
app:layout_constraintStart_toStartOf="@+id/textView6"
app:layout_constraintTop_toTopOf="@+id/textView7" />
<TextView
android:id="@+id/textView9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="90000000000"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/textView4"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="username@gmail.com"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/textView6"
app:layout_constraintTop_toTopOf="@+id/textView6" />
<TextView
android:id="@+id/textView11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="Kolkata"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView8"
app:layout_constraintTop_toBottomOf="@+id/textView10" />
</android.support.constraint.ConstraintLayout>
</android.support.design.card.MaterialCardView>
<android.support.design.button.MaterialButton
android:id="@+id/button5"
style="@style/Button"
android:layout_width="0dp"
android:layout_height="74dp"
android:layout_marginEnd="16dp"
android:text="Payment Status"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button2"
app:layout_constraintTop_toTopOf="@+id/button2" />
<android.support.design.button.MaterialButton
android:id="@+id/button2"
style="@style/Button"
android:layout_width="0dp"
android:layout_height="74dp"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
android:text="Admission Details"
app:layout_constraintEnd_toStartOf="@+id/button5"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/materialCardView" />
<android.support.design.button.MaterialButton
android:id="@+id/button3"
style="@style/Button"
android:layout_width="0dp"
android:layout_height="74dp"
android:layout_marginTop="16dp"
android:text="Rules and Regulation"
app:layout_constraintEnd_toEndOf="@+id/button2"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/button2"
app:layout_constraintTop_toBottomOf="@+id/button2" />
<android.support.design.button.MaterialButton
android:id="@+id/button4"
style="@style/Button"
android:layout_width="0dp"
android:layout_height="74dp"
android:text="Leave"
app:layout_constraintEnd_toEndOf="@+id/button5"
app:layout_constraintStart_toStartOf="@+id/button5"
app:layout_constraintTop_toTopOf="@+id/button3" />
<android.support.design.button.MaterialButton
android:id="@+id/button6"
style="@style/Button"
android:layout_width="184dp"
android:layout_height="74dp"
android:layout_marginStart="64dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="64dp"
android:text="Attendance"
app:layout_constraintEnd_toEndOf="@+id/button4"
app:layout_constraintStart_toStartOf="@+id/button3"
app:layout_constraintTop_toBottomOf="@+id/button3" />
<android.support.design.button.MaterialButton
android:id="@+id/button7"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginEnd="12dp"
android:text="Log out"
app:icon="@drawable/exit"
app:layout_constraintBottom_toTopOf="@+id/space3"
app:layout_constraintEnd_toEndOf="@+id/materialCardView" />
<Space
android:id="@+id/space3"
android:layout_width="1dp"
android:layout_height="15dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="@+id/materialCardView"
app:layout_constraintEnd_toEndOf="@+id/materialCardView"
app:layout_constraintHorizontal_bias="0.882"
app:layout_constraintStart_toStartOf="@+id/button7"
app:layout_constraintTop_toTopOf="@+id/materialCardView"
app:layout_constraintVertical_bias="0.227" />
</android.support.constraint.ConstraintLayout>
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintVertical_weight="1"
android:scaleType="centerCrop"
app:layout_constraintBottom_toTopOf="@+id/materialCardView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/loginn" />
<Space
android:id="@+id/space"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView4"
app:layout_constraintEnd_toEndOf="@+id/imageView4"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/imageView4"
app:layout_constraintTop_toTopOf="@+id/imageView4"
app:layout_constraintVertical_bias="1.0" />
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:text="Firstname Lastname"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@color/white"
app:layout_constraintBottom_toTopOf="@+id/materialCardView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView4"
app:layout_constraintVertical_bias="1.0" />
<com.mikhaellopez.circularimageview.CircularImageView
android:id="@+id/profileImage"
android:layout_width="133dp"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:padding="16dp"
android:src="@drawable/loginn"
app:civ_border_color="@color/white"
app:civ_border_width="1dp"
app:civ_shadow="true"
app:civ_shadow_color="#000000"
app:civ_shadow_radius="0"
app:layout_constraintBottom_toTopOf="@+id/textView"
app:layout_constraintEnd_toEndOf="@+id/space"
app:layout_constraintStart_toStartOf="@+id/space"
app:layout_constraintTop_toTopOf="@+id/space"
app:layout_constraintVertical_bias="1.0" />
</android.support.constraint.motion.MotionLayout>
Хотя вторая плавающая закусочная выглядит лучше, я не могу воспроизвести ее ни при каких других действиях. Я пробовал один и тот же код на другом макете движения, и закусочная выглядит нормально.