项目种遇到一个问题,splash页面到主页面转场黑屏
![image.png](https://upload-images.jianshu.io/upload_images/7037114-4a7b48b103115387.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="com.ttlock.roommaster.home.vm.HomeViewModel" />
<import type="android.view.View" />
<variable
name="daySummary"
type="com.ttlock.roommaster.home.model.DaySummaryObj" />
<variable
name="clickListener"
type="android.view.View.OnClickListener" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/radius_solid_white_bg">
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_key"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/user_keys"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_phone_unlock"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/tv_contract_management"
app:layout_constraintTop_toTopOf="parent" />
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_contract_management"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/category_contract_management"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_contract"
app:layout_constraintLeft_toRightOf="@id/tv_key"
app:layout_constraintRight_toLeftOf="@+id/tv_renter"
app:layout_constraintTop_toTopOf="@id/tv_key" />
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_renter"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/tenant"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_guest"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tv_contract_management"
app:layout_constraintTop_toTopOf="@id/tv_contract_management" />
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_employee_name"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/category_employee"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_staff"
app:layout_constraintEnd_toStartOf="@id/tv_meter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_key" />
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_meter"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/tv_meter"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_lock"
app:layout_constraintEnd_toStartOf="@+id/tv_fee"
app:layout_constraintStart_toEndOf="@id/tv_employee_name"
app:layout_constraintTop_toTopOf="@id/tv_employee_name" />
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_fee"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/module_fee"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_fee"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tv_meter"
app:layout_constraintTop_toTopOf="@id/tv_meter" />
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_rental"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/module_rental"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_rental"
app:layout_constraintEnd_toStartOf="@id/tv_msg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_employee_name" />
<View
android:id="@+id/v_pop_rental"
android:layout_width="21.5dp"
android:layout_height="11dp"
android:background="@drawable/pop_bg"
android:visibility="@{daySummary.rentCollectNum==0 ? View.GONE:View.VISIBLE}"
app:layout_constraintCircle="@id/tv_rental"
app:layout_constraintCircleAngle="120"
app:layout_constraintCircleRadius="12dp"
app:layout_constraintEnd_toEndOf="@id/tv_rental"
app:layout_constraintStart_toStartOf="@id/tv_rental"
tools:ignore="MissingConstraints" />
<TextView
android:id="@+id/tv_pop_rental"
style="@style/text_10dp_white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@{String.valueOf(daySummary.rentCollectNum)}"
android:visibility="@{daySummary.rentCollectNum==0 ? View.GONE:View.VISIBLE}"
app:layout_constraintCircle="@id/v_pop_rental"
tools:ignore="MissingConstraints" />
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_msg"
style="@style/text_12dp_black"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/category_msg"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_message"
app:layout_constraintEnd_toStartOf="@id/tv_repair"
app:layout_constraintStart_toEndOf="@id/tv_rental"
app:layout_constraintTop_toTopOf="@id/tv_rental" />
<View
android:id="@+id/v_pop_msg"
android:layout_width="11dp"
android:layout_height="11dp"
android:background="@drawable/pop_red_point"
android:visibility="@{daySummary.hasNewMessage==1 ? View.VISIBLE:View.GONE}"
app:layout_constraintCircle="@id/tv_msg"
app:layout_constraintCircleAngle="35"
app:layout_constraintCircleRadius="24dp"
tools:ignore="MissingConstraints" />
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_repair"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/repair"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_repair"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tv_msg"
app:layout_constraintTop_toTopOf="@id/tv_msg"
/>
<View
android:id="@+id/v_pop"
android:layout_width="21.5dp"
android:layout_height="11dp"
android:background="@drawable/pop_bg"
android:gravity="center"
android:visibility="@{daySummary.repairNum==0 ? View.GONE:View.VISIBLE}"
app:layout_constraintCircle="@id/tv_repair"
app:layout_constraintCircleAngle="120"
app:layout_constraintCircleRadius="12dp"
tools:ignore="MissingConstraints" />
<TextView
android:id="@+id/tv_pop"
style="@style/text_10dp_white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{String.valueOf(daySummary.repairNum)}"
android:visibility="@{daySummary.repairNum==0 ? View.GONE:View.VISIBLE}"
app:layout_constraintCircle="@id/v_pop"
tools:ignore="MissingConstraints" />
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_hardware"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/hardware"
android:visibility="@{viewModel.isShowCard==false? View.GONE : View.VISIBLE}"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_lock"
app:layout_constraintEnd_toEndOf="@id/tv_key"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_rental" />
<!-- "-->
<!-- <com.hxd.custom.CenterIconTextView
android:id="@+id/tv_net_router"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/module_link"
android:visibility="invisible"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_gateway"
app:layout_constraintEnd_toStartOf="@id/tv_empty"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="@id/tv_hardware"
app:layout_constraintTop_toTopOf="@id/tv_hardware" />
<!– android:visibility="@{viewModel.isShowCard==false? View.GONE : View.VISIBLE}"–>
<com.hxd.custom.CenterIconTextView
android:id="@+id/tv_empty"
style="@style/text_12dp_two_status"
android:layout_width="0dp"
android:layout_height="@dimen/menu_item_height"
android:background="@drawable/click_transparent_layout_bg"
android:gravity="center_horizontal"
android:includeFontPadding="false"
android:onClick="@{clickListener}"
android:text="@string/module_link"
android:visibility="invisible"
app:iconColor="@color/color_primary_selector"
app:iconPadding="4dp"
app:iconSize="32dp"
app:iconTop="@string/ic_home_gateway"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="@id/tv_net_router"
app:layout_constraintTop_toTopOf="@id/tv_hardware" />-->
<!-- android:visibility="@{viewModel.isShowCard==false? View.GONE : View.VISIBLE}"-->
<View
android:id="@+id/expand_collapse_bg"
android:layout_width="match_parent"
android:layout_height="@dimen/list_menu_item_height"
android:onClick="@{clickListener}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_hardware" />
<TextView
android:id="@+id/expand_text"
android:layout_width="wrap_content"
android:layout_height="@dimen/list_menu_item_height"
android:text="@{viewModel.isShowCard==false? @string/expand : @string/collapse}"
app:layout_constraintBottom_toBottomOf="@id/expand_collapse_bg"
android:gravity="center_vertical"
android:textColor="@color/colorPrimary"
app:layout_constraintEnd_toStartOf="@id/expand_icon"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="@id/expand_collapse_bg"
app:layout_constraintTop_toTopOf="@id/expand_collapse_bg" />
<TextView
android:id="@+id/expand_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@{viewModel.isShowCard==false? @string/ic_expand : @string/ic_collapse}"
android:textColor="@color/colorPrimary"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="@id/expand_collapse_bg"
app:layout_constraintEnd_toEndOf="@id/expand_collapse_bg"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/expand_text"
app:layout_constraintTop_toTopOf="@id/expand_collapse_bg" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
tv_hardware 布局种:
tv_rental
改成tv_key
tv_key
黑屏消失。