Different resolution support android

前端 未结 8 1331
北海茫月
北海茫月 2020-11-22 04:21

Edited Question:

Mobile Resolution:
I would like to design different screen dpi like following resolutions.
320x480,
48

8条回答
  •  -上瘾入骨i
    2020-11-22 04:55

    First your application design for one resolution .

    example : suppose your mobile resolution 380*480

           mobile screen width:380
    
           textView size is 80dp   
           Assume : if width is 380dp then 100 % then
    
                   textview width 80dp then how many %(per).
    
                ower answer is: 25 %
    

    find screen size programmatically using belove formula

        DisplayMetric  displaymetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
        ScreenHeight = displaymetrics.heightPixels;
        ScreenWidth = displaymetrics.widthPixels;
            txt_height = (int)((ScreenHeight*14.58)/100);
        txt_width = (int)((ScreenWidth*37.5)/100);
    
    
        LinearLayout.LayoutParams normal_param = new LinearLayout.LayoutParams(txt_height ,txt_width );
    
        txt_Name.setLayoutParams(normal_param);
    

提交回复
热议问题