I have created one Android application.
When I run my application in Mobile Phone it works very well, but when I run in Tablet the layout of application is changed.
So, how to make responsive Android application which is used in Mobile and also in Tablet?
On Android we can use screen size selector, introduced from Android 3.2, to define which layout to use. More details available at http://android-developers.blogspot.in/2011/07/new-tools-for-managing-screen-sizes.html. 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 keeping separator. This is explain in details at : http://www.vanteon.com/downloads/Scaling_Android_Apps_White_Paper.pdf
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