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.
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.
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 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.
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.
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
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With