创建多屏支持应用程序android [英] Creating multi-screen support app android
问题描述
我正在 Android 中创建一个必须支持多屏幕的应用.
I am creating a app in Android that must support multiple screens.
为此,我阅读了许多答案,我最喜欢的一个是声明我可以通过以下名称在 res 文件夹中创建不同的文件夹,
For this purpose i have read many answers and one which i like most is state that i can create different folders in res folder by following name,
对于小屏幕layout-small,
对于大屏幕layout-large,
对于超大屏幕layout-xlarge
而且我必须为具有相同名称的不同屏幕创建不同的布局.例如 mylayout.xml
and i have to create different layouts for different screens with same name. e.g mylayout.xml
我必须将以下代码放在 manifest.xml 文件中
and i have to put following code in manifest.xml file
<supports-screens android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" />
最后我只需要在我的活动文件中写下以下几行,
and finally i just need to write following lines in my Activity file,
setContentView(R.layout.mylayout);
现在当我在不同尺寸的屏幕上运行这个应用程序时,它应该根据屏幕分辨率从不同的文件夹中获取布局.
Now when i run this app in different size screens it should acquire layouts from different folders as per screen resolution.
但在我的情况下不会发生这种情况.它只需要在 layout 文件夹中定义的布局.
But this is not happening in my case.It takes only layout that defined in layout folder.
请有人解释一下为什么会发生这种情况,我该如何解决这个问题,以便我的应用程序可以在所有尺寸的屏幕上有效运行.
Please can some one explains me why this happening and how can i solve this issue so that my app can run effectively on all size screens.
推荐答案
尝试:
- layout-sw320dp
- layout-sw480dp
- layout-sw600dp
- layout-sw720dp
代替
- 布局小,
- layout-large 等...
这篇关于创建多屏支持应用程序android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!