Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我的项目不支持多设备屏幕视图_Android_Xml_Size_Screen - Fatal编程技术网

Android 我的项目不支持多设备屏幕视图

Android 我的项目不支持多设备屏幕视图,android,xml,size,screen,Android,Xml,Size,Screen,我有一个菜单屏幕XML。当我打开项目宽屏幕时,它并没有适应所有屏幕大小。我怎样才能克服这个问题 当我想添加有关此问题的图片时,我想我需要10个代表点:) 有人能帮我吗 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ScrollView1" android:layout_width="match_parent" android:layout_height="mat

我有一个菜单屏幕XML。当我打开项目宽屏幕时,它并没有适应所有屏幕大小。我怎样才能克服这个问题

当我想添加有关此问题的图片时,我想我需要10个代表点:)

有人能帮我吗

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/samsun"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:text="@string/samsun"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/trabzon"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:text="@string/trabzon"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/adana"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:text="@string/adana"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/antalya"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:text="@string/antalya"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/izmir"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/izmir"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/bursa"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/bursa"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/istanbul1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/gayrettepe"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/istanbul2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/acibadem"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/erzurum"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/erzurum"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/diyarbakir"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/diyarbakir"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/ankara"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/ankara"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/kayseri"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/kayseri"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/alcatel"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/alcatel"
            android:textColor="#FFFF" />

        <Button
            android:id="@+id/huawei"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/huawei"
            android:textColor="#FFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/backbone"
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:background="@drawable/selector"
            android:padding="10dp"
            android:text="@string/backbone"
            android:textColor="#FFFF" />



    </LinearLayout>
</LinearLayout>


声明尺寸值小、值大、值大等

不要忘记在AndroidManifest.xml中声明支持屏幕

 <supports-screens 
        android:smallScreens="true" 
        android:normalScreens="true" 
        android:largeScreens="true"
        android:xlargeScreens="true"  
        android:anyDensity="true"/>


有关更多信息,请参阅。

在android中,为了支持尽可能多的设备,可以为一个布局提供多个定义。首先,您需要将这些文件夹添加到资源中,对于每个文件夹,您可以指定相同布局的不同xml文件,以满足您希望应用程序在设备屏幕上使用的要求

下面是一个关于文件夹结构的示例:

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
res/layout-large/my_layout.xml       // layout for large screen size
res/layout-xlarge/my_layout.xml      // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

res/layout/main_activity.xml           // For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml   // For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   // For 10” tablets (720dp wide and bigger)
(应用程序内清单)



关于支持多屏幕的更多信息,我强烈建议阅读谷歌文档。是指向文档的链接

在android中,您必须根据屏幕大小设置不同的可绘制图像,并根据屏幕大小进行布局

res/layout/my_layout.xml(drawable also like layout) ---- default layout. 
res/layout-layout-hdpi/my_layout.xml ---- layout for hdpi screen size 
res/layout-layout-large-hdpi/my_layout.xml ---- layout for large hdpi screen size 
res/layout-layout-mdpi/my_layout.xml ---- layout for mdpi screen size(normal tables also) 
res/layout-layout-Xdpi/my_layout.xml ---- layout for Xhdpi screen Size(high resolution)
您可以按以下步骤进行操作
res/layout/my_layout.xml//正常屏幕大小的布局(“默认”)
res/layout small/my_layout.xml//小屏幕布局
res/layout large/my_layout.xml//大屏幕布局
res/layout xlarge/my_layout.xml//超大屏幕布局
res/layout xlarge land/my_layout.xml//面向景观的超大布局
适用于手机的res/layout/main_activity.xml(小于600dp的可用宽度)
res/layout-sw600dp/main_activity.xml适用于7英寸平板电脑(600dp宽和更大)
res/layout-sw720dp/main_activity.xml适用于10英寸平板电脑(720dp宽和更大)
res/drawable mdpi/my_icon.png//中等密度位图
res/drawable hdpi/my_icon.png//高密度位图
res/drawable xhdpi/my_icon.png//超高密度位图

是的,只需在图片上发布一个html链接,这将有助于分配!您只需要rep就可以将图片嵌入到您的邮件中。@Mustafa,您可以尝试回答“不客气!”!如果您将其标记为正确答案,我将不胜感激:)correct answer@chris您必须点击数字0旁边的V,两个箭头指向上下,但我刚刚注意到有多个正确答案,所以我让您选择,我不想这样宣称。但是,如果你看到人们花时间回答你的问题,那么你总是可以赢得一些声誉。
res/layout/my_layout.xml(drawable also like layout) ---- default layout. 
res/layout-layout-hdpi/my_layout.xml ---- layout for hdpi screen size 
res/layout-layout-large-hdpi/my_layout.xml ---- layout for large hdpi screen size 
res/layout-layout-mdpi/my_layout.xml ---- layout for mdpi screen size(normal tables also) 
res/layout-layout-Xdpi/my_layout.xml ---- layout for Xhdpi screen Size(high resolution)
You can proceed as following

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
res/layout-large/my_layout.xml       // layout for large screen size
res/layout-xlarge/my_layout.xml      // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

res/layout/main_activity.xml           # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)

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


<supports-screens 
        android:smallScreens="true" 
        android:normalScreens="true" 
        android:largeScreens="true"
        android:xlargeScreens="true"  
        android:anyDensity="true"/>