Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.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 当我在priview中将布局更改为不同尺寸时,设计中出现偏差_Android_Android Layout_Android Emulator_Android Viewpager_Android View - Fatal编程技术网

Android 当我在priview中将布局更改为不同尺寸时,设计中出现偏差

Android 当我在priview中将布局更改为不同尺寸时,设计中出现偏差,android,android-layout,android-emulator,android-viewpager,android-view,Android,Android Layout,Android Emulator,Android Viewpager,Android View,我正在开发一个新的Android应用程序。我需要在我的应用程序中设计下面的屏幕截图。我正在使用EclipseIDE 使用下面的代码,我形成了上面显示的屏幕截图。但是,每当我选择不同的屏幕预览(4.7英寸WXGA、4.0英寸WXGA等)时,我都会看到下面屏幕快照中用箭头标记的内部图像未对齐。下面是一个示例的屏幕截图。布局中的所有图像都是图标(例如,主页、共享) 因此,每当我改变不同尺寸的屏幕时,我需要将samller图像(用箭头标记的图标)固定在相同的位置(直线) 有人能给我一些代码片段或

我正在开发一个新的Android应用程序。我需要在我的应用程序中设计下面的屏幕截图。我正在使用EclipseIDE

使用下面的代码,我形成了上面显示的屏幕截图。但是,每当我选择不同的屏幕预览(4.7英寸WXGA、4.0英寸WXGA等)时,我都会看到下面屏幕快照中用箭头标记的内部图像未对齐。下面是一个示例的屏幕截图。布局中的所有图像都是图标(例如,主页、共享)


因此,每当我改变不同尺寸的屏幕时,我需要将samller图像(用箭头标记的图标)固定在相同的位置(直线)


有人能给我一些代码片段或链接来指导我吗。

@2Vision2:造成这个问题的原因是您在布局组件中使用了固定边距

为了支持各种尺寸的设备,您必须创建不同的布局。您正面临这个问题,因为您只使用单一布局。在应用程序的res/directory中为所有大小的布局创建4个目录

  • 布局图(适用于4英寸以下的设备)
  • 布局图-800X480(适用于4英寸以上和5英寸以下的设备)
  • 布局图-sw620dp(适用于7英寸片剂)
  • 布局图-sw800dp(适用于10英寸片剂)

另外,如果要为横向模式创建不同的布局,则也要为横向模式下的支持应用程序创建布局栏、布局栏-800X480、…目录。

@2Vision2:此问题是由于您在布局组件中使用了固定边距造成的

为了支持各种大小的设备,您必须创建不同的布局。您正面临此问题,因为您只使用单个布局。在应用程序的res/directory中为所有大小的布局创建4个目录

  • 布局图(适用于4英寸以下的设备)
  • 布局图-800X480(适用于4英寸以上和5英寸以下的设备)
  • 布局图-sw620dp(适用于7英寸片剂)
  • 布局图-sw800dp(适用于10英寸片剂)

另外,如果要为景观模式创建不同的布局,请创建布局用地,layout-land-800X480,。。在横向模式下支持应用程序的目录。

试试这个xml文件,它将在所有大小(陆地和港口)中通用!事实上,你可能使用了错误的方法来使用重量。 希望这能帮助你了解如何使用重量来设置布局和重力

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight=".75" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight=".25"
        android:background="@android:color/darker_gray" >

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".20"
            android:gravity="center" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_launcher" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".60"
            android:gravity="center|top" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_launcher" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".20"
            android:gravity="center" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_launcher" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

权重也可以用在相对布局中,但最好用线性布局


还有任何疑问,请询问…

试试这个xml文件,它将在所有大小(陆地和港口)中通用!事实上,你可能使用了错误的方法来使用重量。 希望这能帮助你了解如何使用重量来设置布局和重力

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight=".75" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight=".25"
        android:background="@android:color/darker_gray" >

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".20"
            android:gravity="center" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_launcher" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".60"
            android:gravity="center|top" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_launcher" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight=".20"
            android:gravity="center" >

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_launcher" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

权重也可以用在相对布局中,但最好用线性布局


还有任何疑问,请询问……

放弃线性布局。了解RelativeLayout,重做XML(顺便说一下,XML不是代码,它是数据),如果需要更多帮助,请返回。放弃线性布局。了解RelativeLayout,重做您的XML(顺便说一句,XML不是代码,它是数据),如果您需要更多帮助,请回来。谢谢您的回答。这有助于回答问题。有帮助