I read this official link because i want to set different XML for larger screen.
First, i checked my device's width (in dp
) with this code :
private void getScreenDp() {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
float dpHeight = displayMetrics.heightPixels / displayMetrics.density;
float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
}
The width is 320dp.
Then i create a new folder called layout-sw320dp
. When i run the app in 320dp
width device, its using layout-sw320dp
correctly.
However, the layout that my apps used when running in 600dp
width device is the one in layout-sw320dp
instead of the normal layout
folder. I tried to change the layout to layout-w320dp
but the devices bigger than 320dp
width still not using the normal layout as it should be.
Please kindly help me, i have spent hours for this.