在android中正确安装imageview中的图像
我有一个超级市场的图标作为图像列表视图。目前,它们没有完全居中,并且被扭曲。请看地图 这是我的行项目布局在android中正确安装imageview中的图像,android,resize,imageview,Android,Resize,Imageview,我有一个超级市场的图标作为图像列表视图。目前,它们没有完全居中,并且被扭曲。请看地图 这是我的行项目布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/highlight_selector">
<ImageView
style="@style/imgPriceStoreLogoSmall"
android:id="@+id/imgStoreLogo"
android:src="@drawable/panda_logo"
/>
<LinearLayout
android:id="@+id/layoutPriceInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="@+id/lblStoreName"
style="@style/lblRowProductName"
android:layout_marginTop="5dp"
android:textColor="@color/black"
android:textSize="24sp"
android:fontFamily="sans-serif-thin"
android:text="Store Full Name"/>
<TextView
android:id="@+id/lblPrice"
style="@style/lblRowOriginalPrice"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_marginTop="5dp"
android:text="SAR 16.95"/>
</LinearLayout>
<ImageView style="@style/imgRowArrowIcon" />
</LinearLayout>
还有我的风格
<style name="imgPriceStoreLogoSmall">
<item name="android:layout_width">80dp</item>
<item name="android:layout_height">80dp</item>
<item name="android:layout_gravity">start</item>
<item name="android:padding">5dp</item>
<item name="android:scaleType">fitXY</item>
<item name="android:contentDescription">@string/app_name</item>
<item name="android:src">@drawable/no_image</item>
</style>
80dp
80dp
开始
5dp
菲特西
@字符串/应用程序名称
@可绘制/无图像
我不知道徽标图像的实际大小,但希望调整大小以很好地适应imageview。感谢您的帮助
谢谢,
Noorul如果服务器映像太大,下面的代码会将映像与示例映像相匹配
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/yousampleimagesizeimage" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:maxHeight="?android:attr/listPreferredItemHeight"
android:maxWidth="?android:attr/listPreferredItemHeight"
android:scaleType="centerCrop"
android:src="@drawable/serverorDynamicimage" />
</LinearLayout>
(或)
使用:
中心裁剪
您使用的宽度和高度为80dp。如果图像小于此高度和宽度,它将被拉伸以适合此区域。如果它很大,它将缩小以适应此区域。我建议使用80x80大小的倍数图像,例如160x160、40x40等
layout_gravity = start means "Push object to the beginning of its container, not changing its size."
鉴于
center_vertical Place object in the vertical center of its container, not changing its size.
您可以使用“居中垂直”将图像垂直居中。对不起,正确的样式是
80dp 80dp start 5dp fitXY@string/app\u name@drawable/no\u image
将缩放类型
从fitXY
更改为fitCenter
fitXY
填充所有可用空间,忽略纵横比@Noorul的可能副本您是如何解决问题的?upls是否可以共享…我有imageview帧的背景图像如何在帧中设置服务器图像?
layout_gravity = start means "Push object to the beginning of its container, not changing its size."
center_vertical Place object in the vertical center of its container, not changing its size.