在不同的屏幕尺寸的Andr​​oid布局 [英] android layout at different screen sizes

查看:135
本文介绍了在不同的屏幕尺寸的Andr​​oid布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图让我周围的屏幕大小头,所以我的应用程序在不同设备上一样。

trying to get my head around screen sizes so my app looks the same on different devices.

我有两个设备银河S3和Galaxy Tab的8都具有相同的屏幕分辨率720×1280,但S3为4.7英寸,而标签为8英寸

I have two devices a galaxy s3 and a galaxy tab 8. both have the same resolution screen 720 x 1280 but the s3 is 4.7 inches while the tab is 8 inches

当我做线性布局我设置填充130的顶部,使得第一TextView的是从顶部等的背景图象不遮蔽130像素。

When I do a linear layout I set padding to 130 at the top so that the first textview is 130 pixels from the top so the image on the background is not obscured.

这是对S3罚款,但是当我加载选项卡上的填充需要更改为190像素,它看起来是一样的。

This is fine on the s3 but when I load it on the tab the padding needs changing to 190 pixels for it to look the same.

我不能让我的头一轮,如果屏幕分辨率的高度是为什么我需要在屏幕上较大的填充两个设备上相同的(1280)

I cant get my head round if the height of the screen resolution is the same (1280) on both devices why do i need larger padding on the screen

有没有制定出如何使TextView的出现在相同的位置两个设备上的一种方式。

is there a way of working out how to make the textview appear on the same location on both devices

任何帮助AP preciated

Any help appreciated

标记

推荐答案

是的,有一种方式。

首先你应该使用DP或SP单元,而不是PX的。在DP单元在考虑有屏幕的屏幕大小和分辨率。你可以看到在这里:

First off all you should use DP or SP unit instead of PX. The DP unit have in consideration the size of the screen and the screen resolution. You can see more in here:

<一个href=\"http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android\">Difference PX之间,DP,倾角和SP在Android的?

你也可以创建一个资源文件夹,并针对不同的设备添加不同的大小。

Also you can create a folder in res and add different sizes for different devices.

例如:

您已经有文件'dimens.xml在那里你可以添加边距和尺寸变量的文件夹价值。

You already have the folder 'values' with the file 'dimens.xml' in there you can add margins and sizes variables.

如果您创建文件夹价值观大'和COPIE文件dimens.xml',你可以改变变量的大小和维护的名字。

If you create the folder 'values-large' and copie the file 'dimens.xml', you can change the sizes of the variables and maintain the name.

在设备的大就从设备的其余部分加载不同的值。

In devices 'large' it will load different values from the rest of the devices.

您可以看到这里的所有文档: http://developer.android.com/引导/做法/ screens_support.html

You can see all documentation in here: http://developer.android.com/guide/practices/screens_support.html

希望它可以帮助你。

这篇关于在不同的屏幕尺寸的Andr​​oid布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆