Maximum width and height for ImageView in Android(Android中ImageView的最大宽度和高度)
本文介绍了Android中ImageView的最大宽度和高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我用
android:maxHeight="100px"
android:maxWidth="250px"
android:minHeight="100px"
android:minWidth="250px"
android:scaleType="centerInside"
此图像视图用于显示从图库或相机中获取的图片.在这两种情况下,图像都不会调整大小以适应 imageview,它只是根据需要拉伸其空间.
This image view is used to show a picture that is obtained from the gallery or camera. In both cases, the image is not resized to fit inside the imageview, it just stretches its space as much as it needs.
知道如何让它保持在这些范围内吗?
Any idea how to make it stay inside those bounds?
<?xml version="1.0" encoding="utf-8"?>
<EditText
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/txtDescription"
android:layout_below="@+id/txtSubject"
android:inputType="textMultiLine"
android:height="80px"
android:hint="@string/description"></EditText>
<EditText
android:layout_height="wrap_content"
android:layout_below="@+id/txtDescription"
android:layout_width="fill_parent"
android:id="@+id/txtMorada"
android:hint="@string/address" />
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@+id/txtMorada"
android:id="@+id/btGPS"
android:layout_alignParentLeft="true"
android:src="QGRyYXdhYmxlL2ljX21lbnVfY29tcGFzcw=="></ImageButton>
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@+id/btGPS"
android:layout_marginTop="25px"
android:id="@+id/imgPoint"
android:src="QGRyYXdhYmxlL2dvb2dsZV9sb2dvX3NtYWxs"
android:maxHeight="100px"
android:maxWidth="250px"
android:minHeight="100px"
android:minWidth="250px"
android:scaleType="centerInside"></ImageView>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@+id/imgPoint"
android:id="@+id/btGallery"
android:layout_below="@+id/btCamera"
android:src="QGRyYXdhYmxlL2ljX21lbnVfZ2FsbGVyeQ=="
android:layout_alignParentRight="true"></ImageButton>
<Button
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginTop="10px"
android:id="@+id/btSubmit"
android:layout_below="@+id/btGallery"
android:text="@string/submit"></Button>
<ImageButton
android:layout_height="wrap_content"
android:id="@+id/btMap"
android:layout_below="@+id/txtMorada"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:src="QGRyYXdhYmxlL2ljX21lbnVfbWFwbW9kZQ=="></ImageButton>
<TextView
android:layout_below="@+id/txtMorada"
android:layout_width="wrap_content"
android:layout_toLeftOf="@+id/btMap"
android:layout_height="wrap_content"
android:id="@+id/lblNewPointLatitude"
android:text="Latitude"></TextView>
<TextView
android:layout_width="wrap_content"
android:layout_toLeftOf="@+id/btMap"
android:layout_height="wrap_content"
android:id="@+id/lblNewPointLongitude"
android:layout_below="@+id/lblNewPointLatitude"
android:text="Longitude"></TextView>
<ImageButton
android:layout_below="@+id/btMap"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@+is/imgPoint"
android:id="@+id/btCamera"
android:layout_marginTop="25px"
android:src="QGRyYXdhYmxlL2ljX21lbnVfY2FtZXJh"
android:layout_alignParentRight="true"></ImageButton>
<Spinner
android:layout_height="wrap_content"
android:id="@+id/spCategoria"
android:layout_width="fill_parent"
android:prompt="@string/spCategoriaPrompt"></Spinner>
<Spinner
android:layout_height="wrap_content"
android:id="@+id/spSubcategoria"
android:layout_below="@+id/spCategoria"
android:layout_width="fill_parent"
android:prompt="@string/spSubcategoriaPrompt"></Spinner>
<EditText
android:layout_height="wrap_content"
android:layout_below="@+id/spSubcategoria"
android:layout_width="fill_parent"
android:id="@+id/txtSubject"
android:hint="@string/subject"></EditText>
</RelativeLayout>
</ScrollView>
推荐答案
试试 adjustViewBounds
属性:
Try the adjustViewBounds
attribute:
android:adjustViewBounds="true"
这篇关于Android中ImageView的最大宽度和高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:Android中ImageView的最大宽度和高度


猜你喜欢
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01