0

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.

davinci.2405
  • 247
  • 1
  • 4
  • 15
  • dp is not a measure of physical size! Delete this question. Read this thread **thoroughly** http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android then if it's still not clear, come back and ask a more detailed question – Olayinka Jul 23 '15 at 11:50

1 Answers1

2

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);
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198