AppBarLayout 中的 ImageView 导致巨大的性能问题
ImageView inside AppBarLayout causes huge performance issues
我想制作一个上面有图像的工具栏,它会在滚动它下面的视图时折叠,但在某些设备上它会导致巨大的性能问题。滚动速度非常慢,我不明白为什么。在 Samsung Galaxy S2 上运行完美,但在 S7 上非常慢。
app_bar_layout.xml
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/toolbar_image"
android:src="@drawable/sky"
android:layout_width="match_parent"
android:layout_height="120dp"
android:scaleType="centerCrop"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/actionbar_size"
android:background="@color/colorPrimary">
<me.grantland.widget.AutofitTextView
android:id="@+id/autofix_toolbar_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxLines="2"
android:gravity="center_vertical"
android:textSize="23sp"
autofit:minTextSize="23sp"
android:text="@string/app_name"
/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<FrameLayout
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
您的天空图像存储在哪个文件夹中?它有多大?我有一个非常相似的问题,结果证明这是因为图像位于错误的可绘制文件夹中并且缩放比例与我预期的不同。看到这个 post:https://littlelostandroid.wordpress.com/2016/04/23/mishaps-with-bitmaps-part-1/
我想制作一个上面有图像的工具栏,它会在滚动它下面的视图时折叠,但在某些设备上它会导致巨大的性能问题。滚动速度非常慢,我不明白为什么。在 Samsung Galaxy S2 上运行完美,但在 S7 上非常慢。
app_bar_layout.xml
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/toolbar_image"
android:src="@drawable/sky"
android:layout_width="match_parent"
android:layout_height="120dp"
android:scaleType="centerCrop"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/actionbar_size"
android:background="@color/colorPrimary">
<me.grantland.widget.AutofitTextView
android:id="@+id/autofix_toolbar_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxLines="2"
android:gravity="center_vertical"
android:textSize="23sp"
autofit:minTextSize="23sp"
android:text="@string/app_name"
/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<FrameLayout
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
您的天空图像存储在哪个文件夹中?它有多大?我有一个非常相似的问题,结果证明这是因为图像位于错误的可绘制文件夹中并且缩放比例与我预期的不同。看到这个 post:https://littlelostandroid.wordpress.com/2016/04/23/mishaps-with-bitmaps-part-1/