[英]ImageView is stretch when not supposed to be - Android
Column 0 is supposed to be a picture of either a red x or a green check mark. 列0应该是红色x或绿色复选标记的图片。 For testing purposes, I have only put an image in for row 1. As seen in the picture below, the red x image is long and stretched out rectangle.
出于测试目的,我仅在第1行放置了一个图像。如下图所示,红色的x图像很长并且呈矩形展开。 I want it to be a small square image.
我希望它是一个小的正方形图像。 The image seems to be the same as displayed below even if I put the layout_width and layout_height to 50dp each, 10dp each, or as I have it below in my code.
即使我将layout_width和layout_height分别设置为50dp,10dp或代码如下所示,该图像似乎也与下面显示的图像相同。 The dimensions of the picture is 100x100 PNG picture -- if that matters.
图片的尺寸为100x100 PNG图片-如果这样的话。
My question is why is the image to stretched out and how would I go about making it a small square image. 我的问题是为什么图像要拉伸,如何将其制作成小正方形图像。 Thank you in advance for your help!
预先感谢您的帮助!
Results.java 结果.java
ImageView q1Image = (ImageView)findViewById(R.id.q1Image);
q1Image.setScaleType(ImageView.ScaleType.FIT_CENTER);
resultsmain.xml resultsmain.xml
<TableRow
android:id="@+id/row4"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:stretchColumns="0,1,2,3"
android:layout_weight="1" >
<ImageView
android:id="@+id/q1Image"
android:layout_width="5dp"
android:layout_height="10dp"
android:layout_weight=".1" />
<TextView
android:id="@+id/q1Question"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:textSize="8sp" />
<TextView
android:id="@+id/q1Answer"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:textSize="8sp"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/q1Verse"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:textSize="8sp"
android:gravity="center_horizontal" />
</TableRow>
Try this: 尝试这个:
<TableRow
android:id="@+id/row4"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:stretchColumns="0,1,2,3"
android:weightSum="1" >
<ImageView
android:id="@+id/q1Image"
android:layout_width="5dp"
android:layout_height="10dp"
android:layout_weight=".1"
/>
<TextView
android:id="@+id/q1Question"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:textSize="8sp" />
<TextView
android:id="@+id/q1Answer"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:textSize="8sp"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/q1Verse"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".2"
android:textSize="8sp"
android:gravity="center_horizontal" />
</TableRow>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.