Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Responsive design [closed]

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

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

like image 686
Khaled Saifullah Avatar asked Dec 26 '13 19:12

Khaled Saifullah


People also ask

What causes ANR Android?

Application Not Responding (ANR) errors are triggered when the UI thread of the application is not responding for more than 5 seconds. You can read more about ANRs and diagnosing ANRs in the Android documentation. Additionally, Crashlytics can help pinpoint specific problematic threads.

How do I make my Android apps fit all screen sizes?

Simple, use relative layout with the set margin code. Set the margins between each text view, button, etc and it will look the same on every phone. android:layout_marginTop="10dp" // change Top to Bottom, Left or Right for what you need.

How do you avoid ANR?

How to prevent an ANR? Stop doing heavy tasks on the main thread. Instead use worker threads such as IntentService, AsyncTask Handler, or another Thread simply.

How do I make my Android app responsive?

The best way to create a responsive layout is to use ConstraintLayout as the base layout in your UI. ConstraintLayout enables you to specify the position and size of each view according to spatial relationships with other views in the layout. All the views can then move and resize together as the screen size changes.


2 Answers

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

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.

But read the documentation and use enter image description here

like image 89
Pablo Pantaleon Avatar answered Nov 15 '22 20:11

Pablo Pantaleon


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

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.

Here are some of the official micro-optimization performance 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.

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.

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).

like image 35
Stephan Branczyk Avatar answered Nov 15 '22 20:11

Stephan Branczyk