Guide for Supporting Multiple Resolutions

来自三星的官方文档,觉得有点用,转了http://developer.samsung.com/technical-doc/view.do;jsessionid=AQpZJ6HoYL96UHXOPYWzLgbeHB9CJHAwXxUBI_v2I89TFCqPIP7B!869970213?v=T000000126

About This Document

This document contains information on how to support devices of different resolutions in one app. 
In order to understand this document, you need to know Android application development related to Layout and Resource.

Display Policy for Samsung Devices

The Aspect ratio policy for smartphones and tablets applies.

  • Smartphone: QHD (2560x1440), HD (1280x720)
  • Tablet: WQXGA (2560x1600), WXGA (1280x800)
Smartphone (16:9) / Tablet (16:10)

Development Guidelines for Multiple Resolutions

In order to support multiple resolutions in one app, you must create a variable layout for the app or web.

  • Instead of creating a fixed layout, create one that can fit any resolution.
  • Create a variable layout so that content can fit in any screen size.
How to Design a Flexible Screen

When creating a layout, use match_parent or weight, instead of fixed dp values, so that resolution is less affected.

  • Do not use fixed values for width or height of the layout. Instead, use match_parent as the values of layout_width and layout_height in the layout file so that the layout is displayed appropriately.
    • wrap_content: The screen is filled as much as there is content.
    • match_parent: The entire screen is filled.
<LinearLayout
	android:layout_width="math_parent"
	android:layout_height="match_parent"
	android:orientation="vertical">
	...
</LinearLayout>

[Sample Code 1] Example of creating a layout with match_parent

  • If it is difficult to create a layout like the above, use layout_weight to create a screen using a ratio value, not a fixed value. When you do so, specify layout_width or layout_height (whichever you want to use a ratio) as 0, and add layout_weight to specify the ratio.
<LinearLayout
	android:layout_width="math_parent"
	android:layout_height="0dp"
	android:layout_weight="1"
	android:orientation="vertical">
	...
</LinearLayout>

[Sample Code 2] Example of creating a layout with weight

How to Support Multiple Resolutions in a Single Screen Layout

To support multiple resolutions, you may use multiple layout files, but using a single layout file makes file maintenance and management easier. When you need to modify part of the layout for different resolutions, it is good to use dimens.xml, which makes it easy to modify.

Save the below name/value in this file. You can refer to it in source code and other layout XML files.

<resources>
	<dimen name="textview_height">25dp</dimen>
	<dimen name="textview_width">150dp</dimen>
	<dimen name="font_size">16sp</dimen>
</resources>

As below, you can use the name/value defined as dimen above in the application's source code.

Resources res = getResources();
float fontSize = res.getDimension(R.dimen.font_size);

As below, you can use the name/value defined as dimen, in the Layout XML file as well.

<TextView
	android:layout_height="@dimen/textview_height"
	android:layout_width="@dimen/textview_width"
	android:textSize="@dimen/font_size"/>

[Sample Code 3] Example of creating a layout with dimension

How to Support Multiple Resolutions in Codes

You can use the DisplayMetrics class to get lots of information about the display within your code, and create a dynamic screen to support many different resolutions.

// Utilize the display information (density, resolution, etc.) that uses the 
DisplayMetrics class in WindowManager.
DisplayMetrics metrics = new DisplayMetrics();
((Activity) mContext).getWindowManager().getDefaultDisplay().getMetrics(metrics);

//Calculate the width of display in pixels.
int DisplayWidth = metrics.widthPixels;

// Calculate the height of display in pixels.
int DisplayHeight = metrics.heightPixels;

[Sample Code 4] Example of calculating screen size within codes, using the DisplayMetrics class

How to Output Images for Different Resolutions

When displaying an image, if you specify ScaleType (place the image in a specific area, place it in the center, etc.), instead of fixing image size or position, you can support many different types of devices.

Options for ImageView.ScaleType
  • MATRIX: Use the received matrix to draw an image.
  • CENTER: Display an image in the center of the display area, without scaling it.
  • CENTER_CROP: Fill the entire display area, maintaining the image ratio, and crop out the rest.
  • FIT_CENTER: Scale the image so that it will not be cropped, and maximize either the width or height.
  • FIT_XY: Fill the entire screen without maintaining the image ratio.
ImageView mImageView = (ImageView)findViewById(R.id.imageView);
mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

[Sample Code 5] Example of specifying ScaleType in codes

<ImageView 
	android:id="@+id/image" 
	android:layout_width="match_parent" 
	android:layout_height="match_parent" 
	android:scaleType=“centerCrop" 
	android:src="@drawable/icon" />

[Sample Code 6] Example of specifying ScaleType in Layout XML file

Multi-Resolution Definition for Android Market

To register a multi-resolution app in Android Market, you must describe the values to support multiple resolutions in the AndroidManifest.xml file. Each value can be defined for the screen range that your app supports. Please note that certain devices might not be shown in Android Market, depending on the values.

  • ① Enter true/false in the screen size to be supported by your app. Depending on the settings, the devices
         shown in Android Market will be affected as well.
  • ② If you set the acceptance of random screen density to "true", the UI will be optimized according to the 
         density of the screen.
  • ③ This is used to create an app for a specific screen. This is not recommended if you want to support multiple
         solutions, because the values affect the devices shown in Android Market.
<?xml version="1.0" encoding="utf-8"?>
	<manifest xmlns:android=http://schemas.android.com/apk/res/android>
		<supports-screens android:resizeable="true"
				  android:smallScreens="true"
				  android:normalScreens="true"
				  android:largeScreens="true"
				  android:xlargeScreens="true"
				  android:anyDensity="true"/>
	  </manifest>

[Sample Code 7] Example of setting suport screens

How to Manage Resources for Supporting Multiple Resolutions

To support multiple resolutions in one app, you can define layout and resource folders for each resolution.

Supporting multiple resolutions with Layout resources

By defining the Layout folder under the Res folder, as below, you can define the layout for multiple or specific resolutions. Below are the rules for creating the Layout folder. You can define each value for the screen range that your app supports. Please note that certain devices might not be shown in Android Market, depending on the values.

layout – Screen width value (dp) – resolution – OS version

If you need to apply a different layout to specific screen size as shown in the screenshot on the right, create a folder with width and resolution, following the rules mentioned above. Then simply insert the XML file in the folder.
If you need a different layout for an OS version, define the target version like the "v19" folder at the bottom. For multi-resolution to which the above rules do not apply, refer to the "layout-resolution" folder. For layouts that do not affect resolution, refer to the "layout" folder.

layout – Screen width value (dp) – resolution – OS version

Supporting multiple resolutions with Drawable resources

By defining the Drawable folder under the Res folder, as below, you can define image resources for multiple or specific resolutions. Below are the rules for creating a folder.

drawable – Screen width value (dp) – resolution – OS version

If you need to apply a different image resource to a specific screen size as shown in the screenshot on the right, create a folder with width and resolution, following the rules mentioned above. Then simply insert the image in the folder.
If you need a different image resource for an OS version, define the target version like the "v19" folder at the bottom. For multi-resolution to which the above rules do not apply, refer to the "drawable-resolution" folder. For images that do not affect resolution, refer to the "drawable" folder.

drawable – Screen width value (dp) – resolution – OS version

Configuration Qualifier

Below are the current qualifiers for device screen characteristics. They are used to select the right resource for the current screen for the Android platform.

Screen Characteristic Qualifier Description
Size small, normal, large, xlarge Screen size type
Density ldpi, mdpi, hdpi, xhdpi, nodpi, tvdpi Density type
Orientation land, port Landscape or portrait mode

Under the project res folder, you can divide resources for each screen characteristic with the combination of <resource_name>-<qualifier>.

e.g.) res/layout-small/my_layout.xml //layout for small screens
       res/drawable-land-mdpi// mdpi drawable for mdpi landscape screens
       res/drawable-port-mdpi// mdpi drawable for mdpi portrait screens
       res/drawable-xhdpi// xhdpi drawable for xhdpi screens

Even if resources for each screen characteristic do not match exactly, the Android platform will find and apply the optimal replacement resource.

e.g.) If a big-screen device does not have layout-large/my_layout.xml but has, 
       layout/my_layout.xml or layout-small/my_layout.xml, use the layout.

Please note that replacement resources only refer to the res folder of a smaller screen. If a small-screen device has a layout only in res/layout-large, it will not be referred to, and an error will occur.

Using the optimal resource and layout for each resolution

This is how the Android platform selects the optimal resource and layout.

< Resource examples >

dawable/
dawable-en/
dawable-fr-rCA/
dawable-en-port/
dawable-en-notouch-12key/
dawable-port-ldpi/
dawable-port-notouch-12key/

< device configuration examples >

Locale = en-GB
Screen orientation = port
Screen pixel density = hdpi
Touchscreen type = notouch
Primary text input method = 12key

Figure2. Flowchart of how Android finds the best-matching resource.

Figure2. Flowchart of how Android finds the best-matching resource.

  1. Remove directories that conflict with the device configuration
    Because the locale is set to en-GB, drawable-fr-rCA/ will be removed.
  2. Check qualifiers in the order of MCC, MNC, and Language.
  3. Try matching.
    If qualifiers do not match, go back to Step 2 and check the next qualifier. When they match, follow Step 4.
  4. Check the directories and remove those that do not have qualifiers.
    drawable/, drawable-port-ldpi/, drawable-port-notouch-12key/
  5. Follow Step 2, 3, and 4 repeatedly until only one directory matches.
    drawable-en/, drawable-en-notouch-12key/will be removed.
    In the above example, drawable-en-port will be selected and used in the last step.
Reference for Developing Resolutions for Samsung Tablets

Below are the types of resolutions for Samsung tablets.

MKT Name Size Resolution key
Galaxy Tab S 10.5 10.5” WQXGA (xhdpi) Recent/Home/Back (H/W key)
Galaxy Tab S 8.4 8.4” WQXGA (xhdpi) Recent/Home/Back (H/W key)
Galaxy Tab 4 8.0 8.0” WXGA (mdpi) Recent/Home/Back (H/W key)
Galaxy Note Pro 12.2 12.2” WQXGA (xhdpi) Recent/Home/Back (H/W key)
Galaxy Tab pro 8.4 8.4” WQXGA (xhdpi) Recent/Home/Back (H/W key)
Galaxy Note 10.1 2014 Edition 10.1” WQXGA (xhdpi) Menu/Home/Back (H/W key)
Galaxy Note 8.0 8.0” WXGA (tvdpi) Menu/Home/Back (H/W key)
Galaxy Tab 3 8.0 8.0” WXGA (tvdpi) Menu/Home/Back (H/W key)
Galaxy Note 10.1 2012 Edition 10.1” WXGA (mdpi) Navigation bar in Display (S/W key)
Galaxy Tab 8.9 LTE 8.9” WXGA (mdpi) Navigation bar in Display (S/W key)
Galaxy Tab 7.7 7.7” WXGA (mdpi) Navigation bar in Display (S/W key)

You must divide navigation keys into those created as S/W buttons on the screen and those as H/W buttons. Also, depending on the model, you need to create a layout for recent keys and menu keys separately.

How to use a new size qualifier

smallestWidth (sw) and available screen height (h) are used. If you use smallestWidth, you can provide each resolution. In order to categorize devices with the S/W navigation bar, you must use the available screen height. Because the height of 46dp (for the height of the navigation bar) exists, if you make the available screen height bigger than 46dp (e.g. 800-46=754), the resource folder might not be referred to. Please remember this. Below are examples of creating resource folders for Samsung tablets.

Galaxy Note 10.1 2012 Edition drawable-sw800dp-mdpi S/W key
Galaxy Note 3 8.0
Galaxy Note 8.0
drawable-sw600dp-tvdpi H/W key
Galaxy Tab 4 8.0 drawable-sw800dp-h1255dp-port-mdpi
drawable-sw800dp-h775dp-land-mdpi
H/W key
Galaxy Note 10.1 2014 Edition
Galaxy Note Pro 12.2
drawable-sw800dp-xhdpi H/W key
How to categorize a Menu key

ViewConfiguration.get(context).hasPermanentMenuKey() is supported in the Android API 14 and later.

References

For more information, please refer to the below chapters.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
东南亚位于我国倡导推进的“一带一路”海陆交汇地带,作为当今全球发展最为迅速的地区之一,近年来区域内生产总值实现了显著且稳定的增长。根据东盟主要经济体公布的最新数据,印度尼西亚2023年国内生产总值(GDP)增长5.05%;越南2023年经济增长5.05%;马来西亚2023年经济增速为3.7%;泰国2023年经济增长1.9%;新加坡2023年经济增长1.1%;柬埔寨2023年经济增速预计为5.6%。 东盟国家在“一带一路”沿线国家中的总体GDP经济规模、贸易总额与国外直接投资均为最大,因此有着举足轻重的地位和作用。当前,东盟与中国已互相成为双方最大的交易伙伴。中国-东盟贸易总额已从2013年的443亿元增长至 2023年合计超逾6.4万亿元,占中国外贸总值的15.4%。在过去20余年中,东盟国家不断在全球多变的格局里面临挑战并寻求机遇。2023东盟国家主要经济体受到国内消费、国外投资、货币政策、旅游业复苏、和大宗商品出口价企稳等方面的提振,经济显现出稳步增长态势和强韧性的潜能。 本调研报告旨在深度挖掘东南亚市场的增长潜力与发展机会,分析东南亚市场竞争态势、销售模式、客户偏好、整体市场营商环境,为国内企业出海开展业务提供客观参考意见。 本文核心内容: 市场空间:全球行业市场空间、东南亚市场发展空间。 竞争态势:全球份额,东南亚市场企业份额。 销售模式:东南亚市场销售模式、本地代理商 客户情况:东南亚本地客户及偏好分析 营商环境:东南亚营商环境分析 本文纳入的企业包括国外及印尼本土企业,以及相关上下游企业等,部分名单 QYResearch是全球知名的大型咨询公司,行业涵盖各高科技行业产业链细分市场,横跨如半导体产业链(半导体设备及零部件、半导体材料、集成电路、制造、封测、分立器件、传感器、光电器件)、光伏产业链(设备、硅料/硅片、电池片、组件、辅料支架、逆变器、电站终端)、新能源汽车产业链(动力电池及材料、电驱电控、汽车半导体/电子、整车、充电桩)、通信产业链(通信系统设备、终端设备、电子元器件、射频前端、光模块、4G/5G/6G、宽带、IoT、数字经济、AI)、先进材料产业链(金属材料、高分子材料、陶瓷材料、纳米材料等)、机械制造产业链(数控机床、工程机械、电气机械、3C自动化、工业机器人、激光、工控、无人机)、食品药品、医疗器械、农业等。邮箱:market@qyresearch.com

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值