所以,我有一个mainLayout.xml
,看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:background="@color/colorPrimary"
android:animateLayoutChanges="true"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.constraint.ConstraintLayout
android:id="@+id/container"
android:layout_width="0dp"
android:layout_height="220dp"
android:background="@color/colorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:animateLayoutChanges="true"
android:visibility="gone">
<include layout="@layout/progress"
android:layout_width="@dimen/start_button_width"
android:layout_height="@dimen/start_button_width"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/..."
app:layout_constraintVertical_bias="0.100000024"
android:layout_marginBottom="8dp"/>
<android.support.constraint.Guideline
android:id="@+id/..."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5"/>
<include layout="@layout/new_layout2"
android:id="@+id/.."
android:layout_width="0dp"
android:layout_height="100dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/..."
android:layout_marginTop="8dp"/>
</android.support.constraint.ConstraintLayout>
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5"/>
<ProgressBar
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/..."
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/..."
android:layout_marginTop="8dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/.."
android:layout_width="0dp"
android:layout_height="wrap_content"
android:transitionGroup="false"
android:clipChildren="false"
android:nestedScrollingEnabled="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/.."/>
每当我在root.visibility = View.VISIBLE
应用程序口吃中调用onViewCreated()
时。如果我没有在根目录上调用VISIBLE(默认值为GONE),则不会出现跳过的帧。
Layout "progress"
-是带有1个ImageView的ConstraintLayout,它不应该很笨重,但是
Layout "new_layout2"
-看起来像这样:
每个包含在内的ConstraintLayout的ProgressBar
和TextView
都有。
Profiler为我提供了这一功能(我对此一无所知,但如果不得不猜测,我对缓慢的UI渲染的假设是正确的):
如何确保更改对根的可见性(我想它是在重绘所有内容?)不会影响应用程序的FPS?我还有其他方法可以解决此问题吗?