2013-05-27 31 views
0

我正在开发和应用它可以在1280 * 800和480 * 320上正常工作,但在挤压imageview和其他小部件的其他设备中工作不正常。请帮助我如何使它成为Android手机的通用应用程序。Android手机的通用应用程序?

+1

你应该阅读这些链接http://developer.android.com/guide/practices/screens_support.html和这个http://developer.android.com/training/multiscreen/screensizes.html –

回答

0

首先您的应用程序设计为一个决议。

例子:假设你的手机分辨率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 % 

发现屏幕尺寸以编程方式使用belove公式

这是一个例子,你可以设置动态的高度和宽度布局

int width=0,height=0,left=0,right=0,top=0,bottom=0; 
DisplayMetrics displaymetrics = new DisplayMetrics(); 
      getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); 
     int ScreenHeight = displaymetrics.heightPixels; 
      int ScreenWidth = displaymetrics.widthPixels; 
/* <Button 
      android:id="@+id/button_classRoomVideos" 
      android:layout_width="95dp" 
      android:layout_height="98dp" 
      android:layout_alignTop="@+id/button_Test" 
      android:layout_marginLeft="83dp" 
      android:layout_toRightOf="@+id/button_Test" 
      android:layout_weight="1" 
      android:background="@drawable/classroom_lectures_videos" />*/ 
      width = (int)((ScreenWidth*9.3)/100); 
      height = (int)((ScreenHeight*14.50)/100); 
      RelativeLayout.LayoutParams params_mVideo; 
      params_mVideo = (RelativeLayout.LayoutParams)mVideoButton.getLayoutParams(); 
      params_mVideo.width=width; 
      params_mVideo.height=height; 
      params_mVideo.setMargins((int)((ScreenWidth*8.1053)/100), 0, 0, 0); 
      mVideoButton.setLayoutParams(params_mVideo); 
+0

我在应用程序的所有活动中都这样做,但它在第一个活动中并不在所有活动中工作,它显示了一些挤压...... :( –

+0

这种技术对我来说很重要,请再次检查它。 – Hemant

+0

尝试处理不同的屏幕比例。 – JiTHiN

相关问题