Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.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 ImageView大小在平板电脑中没有变化_Android_Android Layout - Fatal编程技术网

Android ImageView大小在平板电脑中没有变化

Android ImageView大小在平板电脑中没有变化,android,android-layout,Android,Android Layout,我在android中有一个布局,它有两个图像视图。我已经在不同屏幕的相应可绘制文件夹中提供了这方面的图像。这种布局在手机上看起来不错,但在平板电脑上,图像看起来并没有填满整个可用空间 即使我改变了图像的大小,图像看起来还是一样的,也看不到任何变化。因此,在平板电脑中,图像以某种方式缩小。我不知道我做错了什么 这是我的布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://sch

我在android中有一个布局,它有两个图像视图。我已经在不同屏幕的相应可绘制文件夹中提供了这方面的图像。这种布局在手机上看起来不错,但在平板电脑上,图像看起来并没有填满整个可用空间

即使我改变了图像的大小,图像看起来还是一样的,也看不到任何变化。因此,在平板电脑中,图像以某种方式缩小。我不知道我做错了什么

这是我的布局

 <?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"
   android:background="@drawable/background" >

   <RelativeLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/player_score"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="@string/you"
        android:textColor="@color/text"
        android:textSize="40sp" />

    <TextView
        android:id="@+id/com_score"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:gravity="right"
        android:text="@string/com"
        android:textColor="@color/text"
        android:textSize="40sp" />

 </RelativeLayout>

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

    <ImageView
        android:id="@+id/com_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_gravity="center_horizontal"
        android:contentDescription="@string/image_desc"
        android:paddingTop="0dp"
         />

    <TextView 
        android:id="@+id/status"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/ready"
        android:textColor="@color/text"
        android:textSize="50sp"   />
    <ImageView
        android:id="@+id/player_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_gravity="center_horizontal"
         android:contentDescription="@string/image_desc"
        android:paddingTop="0dp"
        android:paddingBottom="0dp" />
    </LinearLayout>
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/rock"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/button"
            android:textColor="@color/text"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:text="@string/rock"/>
        <View 
            android:layout_width="2dp"
            android:layout_height="match_parent"
            android:background="@color/text"/>
         <Button
            android:id="@+id/paper"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/button"
            android:textColor="@color/text"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:text="@string/paper"/>
         <View 
            android:layout_width="2dp"
            android:layout_height="match_parent"
            android:background="@color/text"/>
          <Button
            android:id="@+id/scissors"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/button"
            android:textColor="@color/text"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:text="@string/scissors"/>
    </LinearLayout>
</LinearLayout>

将0dp用于android:layout\u height并从第二个文本视图中移除权重

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

    <ImageView
        android:id="@+id/com_image"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_gravity="center_horizontal"
        android:contentDescription="@string/image_desc"
        android:paddingTop="0dp"
         />

    <TextView 
        android:id="@+id/status"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/ready"
        android:textColor="@color/text"
        android:textSize="50sp"   />
    <ImageView
        android:id="@+id/player_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
         android:contentDescription="@string/image_desc"
        android:paddingTop="0dp"
        android:paddingBottom="0dp" />
    </LinearLayout>
</LinearLayout>
...
。。。
...

我认为您可以:

  • 将两个
    ImagesView的
    layout\u width
    更改为
    match\u parent
  • 添加
    android:adjustViewBounds=“true”
    (也添加到
    ImageView
    s)

您将这些平板电脑绘图设备放在哪些文件夹中?您将在哪些设备上进行测试?仅供参考,不需要第二个(嵌套)线性布局。视图已经包含在垂直方向的线性布局中,因此将它们包装在另一个线性布局中不会增加任何内容。@Tanis我已将图像放入ldpi、mdpi、hdpi和xhdpi文件夹中。我正在模拟Nexus7上进行测试。@Stephen谢谢你指出这一点。我在底部有3个按钮。因此,移除布局权重不是一个选项。第一种方法有效。但是当
Layout\u width
wrap\u content
时,为什么图像会缩小。我认为它们没有放大:
Layout\u weight
>0提供了额外的垂直空间,但它们也需要水平空间来扩展。