Android的 - 文本定位 [英] Android - Text positioning

查看:139
本文介绍了Android的 - 文本定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的工作(在Java编写的,而不是统一的应用程序一直在努力我的运气)非常,非常,非常简单的应用程序,我有一个背景图像是全屏,这个形象有很大的设计并与每个设备秤好,看上去很不错(每次我们能想到的分辨率测试)。

I have a very, very, very simple application that I'm working on (been trying my luck at writing an app in Java instead of Unity) and I have a background image that is fullscreen, this image has a lot of design and scales well with every device, and looks great (tested on every resolution we can think of).

然而,文本不希望留下属于它的地方,这是不允许的。我们有一个基本的设置,与此类似(但与约6小时设计工作的投入吧)

However the text doesn't want to stay where it belongs, and that's not permissible. We have a basic setup, similar to this (however with about 6 hours of design work put into it):

和我们需要的文本在广场在任何时候都居中。我们怎样才能做到这一点?我们有手动定位并调整其大小为每个分辨率?这似乎是地狱。

and we need text to be centered in the squares at all times. How can we do this? Do we have to manually position and size it for each resolution? That seems like hell.

推荐答案

通过一个的相对布局,如果​​我理解正确的话,箱子将家长和进入框将是孩子们的文字。你可以把你TextViews入框,然后使用的东西,像的android:layout_centerVertical 的android:layout_centerHorizo​​ntal 为了使确保它们居中。请务必使之与显示的密度正确使用缩放 SP 为您的字体大小。

With a relative layout, if I understand correctly, the boxes will be parents and the text that goes into the boxes will be the children. You can put your TextViews into the boxes and then use things like android:layout_centerVertical or android:layout_centerHorizontal in order to make sure they are centered. Make sure to use sp for your font size so that it scales correctly with the density of the display.

这篇关于Android的 - 文本定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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