Reputation: 247
I designed an app for phones and tablets but I have a problem.
I've tested on 10''/7'' tablets and it works fine, but on a 7'' tablets with smallest width = 480.0 it show the layout from the phone.
I have the three folders : layout, layout-sw600dp and layout-sw720dp.
Can you provide me some tips on how to achive that on the 400X800 7'' tablet to enter the tablet layout and not the phone layout?
Many Thanks.
Upvotes: 0
Views: 168
Reputation: 75788
Faced same issue . No need to create 3 different layout folder . Use DisplayMetrics logic. Get your device height & weight . Set layout height & width respect to device height & width(Apply % rule) .
DisplayMetrics metrics = getResources().getDisplayMetrics();
int DeviceTotalWidth = metrics.widthPixels;
int DeviceTotalHeight = metrics.heightPixels;
And set this way,
LinearLayout LL_First_Section=(LinearLayout)findViewById(R.id.Your_Id);
LL_First_Section.getLayoutParams().height= (int) (DeviceTotalHeight*11.21/100);
Upvotes: 2