android - 如何处理 diffrent-2 屏幕分辨率 android 的 xml UI

标签 android

您好,我已经在 xml 中制作了用于显示的 UI,它在 480*800 分辨率尺寸的屏幕上看起来不错,但对于 320*480 或中等尺寸的小尺寸屏幕,UI 看起来失真意味着按钮不在其真实位置。我保存ldpi、hdpi 和 mdpi 文件夹中的所有图像,并授予屏幕支持权限

下面是我的xml

  <?xml version="1.0" encoding="utf-8"?>

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="@drawable/mainmenuimage" 
 >

<Button android:layout_marginTop="230dip" 
android:text="currentloc" 
android:focusable="true"
android:background="@drawable/mainmenubtn" 
android:id="@+id/btn" android:layout_height="50dip"
 android:layout_width="110dip" 
 android:layout_marginLeft="100dip"/>


<Button 

     android:text="Filter"
     android:id="@+id/filter" 
     android:layout_height="50dip"
     android:layout_width="110dip"
     android:layout_marginLeft="100dip"
     android:layout_marginTop="6dip" 
     android:background="@drawable/mainmenubtn"/>

 <Button 
     android:text="keyword search"
     android:id="@+id/keysearch" 
     android:layout_height="50dip"
     android:layout_width="110dip"
     android:layout_marginLeft="100dip"
     android:layout_marginTop="6dip" 
     android:background="@drawable/mainmenubtn"/>

    </LinearLayout>

list 是:

        <supports-screens
             android:anyDensity = "false"
              android:resizeable="true"
              android:smallScreens="true"
              android:normalScreens="true" 
              android:largeScreens="true" 


            />

所以如何处理不同屏幕的布局,我已经阅读了 alreday 在 android 开发人员方面的所有教程....但没有任何......请帮忙谢谢

最佳答案

这篇文章描述了要做什么: http://developer.android.com/guide/practices/screens_support.html

For example, the following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for medium, high, and extra high density screens.

res/layout/my_layout.xml // layout for normal screen size

res/layout-small/my_layout.xml // layout for small

res/layout-large/my_layout.xml // layout for large

res/layout-xlarge/my_layout.xml // layout for extra

res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

res/drawable-mdpi/my_icon.png // bitmap for medium density

res/drawable-hdpi/my_icon.png // bitmap for high density

res/drawable-xhdpi/my_icon.png // bitmap for extra high density

关于android - 如何处理 diffrent-2 屏幕分辨率 android 的 xml UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7453748/

相关文章:

java - 为什么需要显式转换?

javascript - 在 android 中使用 Javascript 桥

Android - 未创建选项卡项

android - java.io.IOException : setDataSource failed when play recorded mp4 异常

java - 当我尝试从 Intent putExtra 时,出现空指针异常

android - Azure 云存储帐户 Android : Acces blob from android

javascript - 谷歌地图 API 错误 : RefererNotAllowedMapError in android device

android - 如何在 android 设备上获取应用程序崩溃详细信息(自己的统一应用程序)

java - NFC标签上的图片

Android 不断缓存我的 Intents Extras,如何声明一个未决的 Intent 来保留新的 Extras?