Try using wrap_content, fill_parent or dp unit in your regular layout. In any case, creating multiple layouts, as you do, is tedious, but perhaps the best option. Set it in your manifest
<supports-screens
android:largeScreens="true"
android:smallScreens="true"
android:normalScreens="true"
/>
and get the screen size used with
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;
Log.e("FirstImage", "Width = "+width+"Height = "+height);
Once you have the screen size, I think you know how to assign it a specific predefined layout.
Hope this helps if you still have any problems, comment below and we will see how to solve it!
source
share