Android 用于工具栏的理想图像大小?
我有一个可折叠的工具栏,我想在后台设置一个图像,我正在使用图像加载程序库来提高性能,即使图像看起来很慢 这是我的工具栏xmlAndroid 用于工具栏的理想图像大小?,android,android-imageview,Android,Android Imageview,我有一个可折叠的工具栏,我想在后台设置一个图像,我正在使用图像加载程序库来提高性能,即使图像看起来很慢 这是我的工具栏xml <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/ctl_scene_list" android:layout_width="match_parent" android:layout_height="match_parent" and
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/ctl_scene_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/iv_production_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@drawable/ph_production_profile_pic"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@color/silver_chalice_approx"
app:layout_collapseMode="none" />
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/black_40_alpha"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<include layout="@layout/toolbar" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
我想对所有类型的分辨率使用单个图像,是否建议使用基于分辨率的图像并在代码中检查分辨率,以及在服务器上上载时图像的理想大小是多少?如果图像是从远程服务器加载的,且分辨率非常高,这可能会影响某些设备的性能 这里有一个建议:您以高分辨率(这将被视为xxhdpi或xxxhdpi)将图像上载到服务器,然后您可以拥有一个服务器脚本,该脚本自动为剩余密度(mdpi、hdpi和xhdpi)创建缩放图像 当您从应用程序的服务器获取图像时,只需获取设备的屏幕密度,并将其作为get/POST变量发送到服务器,以便服务器以正确的分辨率响应图像 要获取设备的屏幕密度,请使用以下代码:
getResources().getDisplayMetrics().density;
以下是android使用的缩放比例:
0.75-ldpi
1.0-mdpi
1.5-hdpi
2.0-xhdpi
3.0-xxhdpi
4.0-xxxhdpi
TL;DR:获取设备的屏幕密度,将其作为Get/POST变量发送到服务器,并让服务器响应该密度的正确图像。如果图像是从远程服务器加载的,且分辨率非常高,可能会影响某些设备的性能 这里有一个建议:您以高分辨率(这将被视为xxhdpi或xxxhdpi)将图像上载到服务器,然后您可以拥有一个服务器脚本,该脚本自动为剩余密度(mdpi、hdpi和xhdpi)创建缩放图像 当您从应用程序的服务器获取图像时,只需获取设备的屏幕密度,并将其作为get/POST变量发送到服务器,以便服务器以正确的分辨率响应图像 要获取设备的屏幕密度,请使用以下代码:
getResources().getDisplayMetrics().density;
以下是android使用的缩放比例:
0.75-ldpi
1.0-mdpi
1.5-hdpi
2.0-xhdpi
3.0-xxhdpi
4.0-xxxhdpi
TL;DR:获取设备的屏幕密度,将其作为Get/POST变量发送到服务器,并让服务器响应该密度的正确图像。图像分辨率是多少?如果它太高,可能不需要,因为它显示在手机上,这可能会增加加载它所需的时间。分辨率为1440*1080,大小为100 KB。这是一个非常高的分辨率,有没有办法缩小它?图像分辨率是多少?如果它太高,可能不需要,因为它显示在手机上,这可能会增加加载它所需的时间。分辨率为1440*1080,大小为100 KB这是一个非常高的分辨率,有没有办法缩小它?