gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 17:46:02 26 4
gpt4 key购买 nike

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

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

这是我的布局

 <?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>

最佳答案

我认为你可以:

  • 将两个 ImagesViewlayout_width 更改为 match_parent
  • 添加 android:adjustViewBounds="true"(也添加到 ImageView)

关于Android ImageView 大小在平板电脑中没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26655133/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com