Android ImageView大小在平板电脑中没有变化
我在android中有一个布局,它有两个图像视图。我已经在不同屏幕的相应可绘制文件夹中提供了这方面的图像。这种布局在手机上看起来不错,但在平板电脑上,图像看起来并没有填满整个可用空间 即使我改变了图像的大小,图像看起来还是一样的,也看不到任何变化。因此,在平板电脑中,图像以某种方式缩小。我不知道我做错了什么 这是我的布局Android ImageView大小在平板电脑中没有变化,android,android-layout,Android,Android Layout,我在android中有一个布局,它有两个图像视图。我已经在不同屏幕的相应可绘制文件夹中提供了这方面的图像。这种布局在手机上看起来不错,但在平板电脑上,图像看起来并没有填满整个可用空间 即使我改变了图像的大小,图像看起来还是一样的,也看不到任何变化。因此,在平板电脑中,图像以某种方式缩小。我不知道我做错了什么 这是我的布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://sch
<?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”
s)ImageView
Layout\u width
是wrap\u content
时,为什么图像会缩小。我认为它们没有放大:Layout\u weight
>0提供了额外的垂直空间,但它们也需要水平空间来扩展。