Android 响应式设计

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20790466/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:28:29  来源:igfitidea点击:

Android Responsive design

androidresponsive-design

提问by Khaled Saif

I am creating an android app. I want it to be responsive for all the android devices of all the density.

我正在创建一个 android 应用程序。我希望它能够响应所有密度的所有 android 设备。

How can I design a layout Responsively for all the android devices ? please help me.

如何为所有 android 设备响应式地设计布局?请帮我。

采纳答案by Pablo Reyes

The better way to support all different sizes is multiple layouts.

支持所有不同尺寸的更好方法是多种布局。

https://developer.android.com/guide/practices/screens_support.html

https://developer.android.com/guide/practices/screens_support.html

All documentation help you about this. In text sometimes is better user small, Medium or High and not a sp.

所有文档都可以帮助您解决这个问题。在文本中,有时更好的用户是小、中或高,而不是 sp。

But read the documentation and use enter image description here

但是阅读文档并使用 enter image description here

回答by Stephan Branczyk

Just follow the Android coding guidelines. They're very good.

只需遵循 Android编码指南即可。他们非常好。

The important thing is not to reinvent the wheel. Follow the Android best practices and conventions whenever you can. They're usually there for a reason. Now if you do something special, things may slow down, but worry about that only if that happens.

重要的是不要重新发明轮子。尽可能遵循 Android 最佳实践和约定。他们通常在那里是有原因的。现在如果你做一些特别的事情,事情可能会变慢,但只有在这种情况发生时才担心。

Here are some of the official micro-optimizationperformance tips in case you're still curious, but like the document says, this is not what you should be worrying about right now.

这里有一些官方的微优化性能提示,以防您仍然好奇,但正如文档所说,这不是您现在应该担心的。

Before you start optimizing, make sure you have a problem that you need to solve. Make sure you can accurately measure your existing performance, or you won't be able to measure the benefit of the alternatives you try. [source]

在开始优化之前,请确保您有需要解决的问题。确保您可以准确衡量您现有的绩效,否则您将无法衡量您尝试的替代方案的好处。 [来源]

Also, before you go looking to support all screen densities. Take a look at the official statistics here. And note that even if you don't optimize for a particular lower density, the Android system will do the scaling itself in most cases without any trouble.

此外,在您寻求支持所有屏幕密度之前。看看这里的官方统计数据。请注意,即使您不针对特定的较低密度进行优化,Android 系统在大多数情况下也会自行进行缩放,不会有任何问题。

If you want to make sure things work on a cheaper/older device, ask your friends if they have one they're about to throw away that they could give you. As developers, we all tend to have the latest and the fastest devices.

如果您想确保在更便宜/更旧的设备上工作,请询问您的朋友是否有他们可以扔掉的设备,他们可以给您。作为开发人员,我们都倾向于拥有最新、最快的设备。

If you test on a device at home or at work, remember that your wifi has unusually low latency, so things may be significantly slower if your app has to fetch things on an actual cellular network.

如果您在家里或工作中的设备上进行测试,请记住您的 wifi 具有异常低的延迟,因此如果您的应用程序必须在实际的蜂窝网络上获取内容,则速度可能会明显变慢。

And if you used to do iOS development/design, or own an iPhone as your primary device, make sure not to design your app like an iOS app, otherwise you'll find yourself writing everything from scratch and butting your head against extremely hard programming problems (that for the most part, the Android framework has already solved for you, if you're just willing to surrender yourself to its process and its conventions).

如果你曾经做过 iOS 开发/设计,或者拥有 iPhone 作为你的主要设备,请确保不要像 iOS 应用程序一样设计你的应用程序,否则你会发现自己从头开始编写所有内容,并与极其困难的编程产生冲突问题(在大多数情况下,Android 框架已经为您解决了,如果您只是愿意屈服于它的过程和约定)。