How to make responsive Android applications for mobile devices and tablets?
•
Android
I created an Android application
When I run my application on my mobile phone, it works well, but when I run in tablet, the layout of the application changes
So how do you make responsive Android applications for mobile and tablet computers?
resolvent:
On Android, we can use the screen size selector introduced from Android 3.2 to define the layout to be used. For more details, please visit http://android-developers.blogspot.in/2011/07/new-tools-for-managing-screen-sizes.html. The following code snippet has been extracted from the same link:
public class MyActivity extends Activity
{
@Override protected void onCreate(Bundle savedInstanceState)
{
super.onCreate();
Configuration config = getResources().getConfiguration();
if (config.smallestScreenWidthDp >= 600)
{
setContentView(R.layout.main_activity_tablet);
}
else
{
setContentView(R.layout.main_activity);
}
}
}
Another good reference for size configuration is the holding separator. The detailed explanation is as follows: http://www.vanteon.com/downloads/Scaling_ Android_ Apps_ White_ Paper.pdf
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码