目前我正试图在活动的顶部设置背景图片。 规格的图像:背景图片缓慢的应用程序下降
高度:290dp 宽度:match_parent ScaleType:cropCenter
背景图像被存储在@drawables。图像的大小为750 x 600像素。 这是41.3 KB大。
我活动的XML看起来是这样的:
<RelativeLayout
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="match_parent"
android:background="#E6E6E6">
<ImageView
android:layout_height="290dp"
android:layout_width="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/background_rocket">
</ImageView>
<ListView
android:id="@+id/list"
android:paddingTop="240dp"
android:clipToPadding="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbarStyle="outsideOverlay"
android:divider="@android:color/transparent"
android:listSelector="@android:color/transparent"
android:descendantFocusability="blocksDescendants">
</ListView>
</RelativeLayout>
这正是我想要的,但它是可怕的慢(当我上运行它我的S8)。当我向下滚动时,它会卡住。当我在Android Studio模拟器上运行它时,它可以正常工作(我认为速度稍慢一些,但在真实手机上要好得多)。
我已经下载了插件:Drawable Importer。
但它并没有帮助。
注意:自定义ListView Adapter
应该没问题,因为当我删除ImageView
它运行平稳。
如果将'android:background =“#E6E6E6”'更改为'“@ drawable/background_rocket”',是否有区别? – pskink
@pskink不,不变。但是,谢谢。 – MyNewName
@pskink是的,我正在使用自定义的'Adapater'。 'GetView'方法的内容:'if(convertView == null) convertView = mContext.getLayoutInflater()。inflate(R.layout.list_item_person,null);返回convertView;' – MyNewName