简体   繁体   English

Android 4.0不同的屏幕尺寸和密度

[英]Android 4.0 Different Screen Size and Density

This is main activity screen of my application.But I do not provide same view in different screen size and density.Please help me.How can I solve this problem.I want to use this xml layout with android API 10 and higher.I tried most of techniques solve this problem but I did not. 这是我的应用程序的主要活动屏幕。但是在不同的屏幕尺寸和密度下我没有提供相同的视图。请帮帮我。如何解决这个问题。我想将此xml布局与android API 10及更高版本一起使用。大多数技术都可以解决此问题,但我没有。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:animateLayoutChanges="true"
android:background="@drawable/home"
>



<RelativeLayout
    android:id="@+id/topheader"
    android:layout_width="match_parent"
    android:layout_height="142dip"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" >
</RelativeLayout>

<RelativeLayout
    android:id="@+id/RelativeLayout1"
    android:layout_width="wrap_content"
    android:layout_height="320dip"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" >

    <include
        android:id="@+id/include2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/include3"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="20dip"
        layout="@layout/anaekran_seconddock" />

    <include
        android:id="@+id/include1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/include2"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="20dip"
        layout="@layout/anaekran_firstdock" />

    <include
        android:id="@+id/include3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="30dip"
        layout="@layout/anaekran_thirddock" />
</RelativeLayout>

<RelativeLayout
    android:id="@+id/relativeLayout2"
    android:layout_width="match_parent"
    android:layout_height="142dip"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/topheader"
    android:background="@color/gray" >

    <Gallery
        android:id="@+id/gallery1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RelativeLayout>

you can create different xml files for different screen sizes and put them in their respective folders . 您可以为不同的屏幕尺寸创建不同的xml文件,并将它们放在各自的文件夹中。

for example for medium screen size put the .xml in res/layout-medium folder. 例如,对于中等大小的屏幕,请将.xml放入res / layout-medium文件夹中。 for large--- res/layout-large for extralarge---res/layout-xlarge 适用于大型--- res / layout-large适用于超大型--- res / layout-xlarge

the name of all the xml files must be same in all the folders. 所有xml文件的名称在所有文件夹中必须相同。 for more information read this 有关更多信息,请阅读

You can not specify a certain layout for a certain API leverl. 您不能为特定的API指定特定的布局。 You can limit you application to be run on minimum and maximum API levels using the following in your manifest file: 您可以使用清单文件中的以下内容来限制您的应用程序在最低和最高API级别上运行:

 <uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="17" />

if you want to use particular layouts for certain screen sizes you can do that by putting different layout xml files in the res/layout-land or res/layout-normal or res/layout-large, ect. 如果您想为特定的屏幕尺寸使用特定的布局,可以通过在res / layout-land或res / layout-normal或res / layout-large等中放置不同的布局xml文件来实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM