Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.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_View_Android Imageview - Fatal编程技术网

Android 放置两个图像以占据整个屏幕

Android 放置两个图像以占据整个屏幕,android,view,android-imageview,Android,View,Android Imageview,我想在各自的图像视图中放置两个图像,以便它们占据整个屏幕。到目前为止,我只得到了:((要添加正在测试的设备,我使用S3) 图像为1080 X 1920,缩放到屏幕。问题是下面的图像缩放不正确或连接不正确。我在顶部和底部有一个黑色区域 很抱歉,图像大小不一样。 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android

我想在各自的图像视图中放置两个图像,以便它们占据整个屏幕。到目前为止,我只得到了:((要添加正在测试的设备,我使用S3)


图像为1080 X 1920,缩放到屏幕。问题是下面的图像缩放不正确或连接不正确。我在顶部和底部有一个黑色区域

很抱歉,图像大小不一样。


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="2" >

<ImageView
    android:id="@+id/white"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:onClick="onClick"
    android:src="@drawable/up" />

<ImageView
    android:id="@+id/blue"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:onClick="onClick"
    android:src="@drawable/blue" />

</LinearLayout>

您应该使用带有
布局重量设置的线性布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
<ImageView
    android:id="@+id/white"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:onClick="onClick"
    android:src="@drawable/up" />

<ImageView                
    android:id="@+id/blue"
    android:layout_height="0dp"
    android:layout_width="fill_parent"
    android:layout_weight="1"
    android:src="@drawable/blue"
    android:onClick="onClick"
    android:layout_below="@id/white"/>
</LinearLayout>


对于缩放问题,我建议查看您应该使用带有
布局权重设置的线性布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
<ImageView
    android:id="@+id/white"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:onClick="onClick"
    android:src="@drawable/up" />

<ImageView                
    android:id="@+id/blue"
    android:layout_height="0dp"
    android:layout_width="fill_parent"
    android:layout_weight="1"
    android:src="@drawable/blue"
    android:onClick="onClick"
    android:layout_below="@id/white"/>
</LinearLayout>


对于缩放问题,我建议您研究一下

您可以通过添加weightSum来实现这一点

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity1" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:weightSum="1" >

        <ImageView
            android:id="@+id/white"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight=".5"
            android:onClick="onClick"
            android:src="@drawable/up" />

        <ImageView
            android:id="@+id/blue"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_below="@id/white"
            android:layout_weight=".5"
            android:onClick="onClick"
            android:src="@drawable/blue" />
    </LinearLayout>

</RelativeLayout>

它看起来像:
有关更多帮助,请添加注释。

您可以通过添加weightSum来实现此目的。替换此xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity1" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:weightSum="1" >

        <ImageView
            android:id="@+id/white"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight=".5"
            android:onClick="onClick"
            android:src="@drawable/up" />

        <ImageView
            android:id="@+id/blue"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_below="@id/white"
            android:layout_weight=".5"
            android:onClick="onClick"
            android:src="@drawable/blue" />
    </LinearLayout>

</RelativeLayout>

它看起来像:
更多帮助。请添加注释。

查看此处:查看此处:图像的大小与我之前应该添加的大小不同。这不是一个问题,您可以为图像设置缩放类型。如果需要,您可以根据自己的意愿设置高度值。再添加一项设置线性布局的方向类型图像的si不相同ze我以前应该添加这个。这不是一个问题,您可以为图像设置缩放类型。如果需要,您可以根据自己的意愿设置高度值。再添加一项设置线性布局的方向类型