在实际开发中,我们可以将一个图像文件,指定显示按照屏幕的大小进行显示,或者对指定的图像文件进行裁剪的功能。下面介绍实现适屏和裁剪图片的功能。
一、建立工程,如图
二、activity_main.xml中代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:andro>
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:layout_width="fill_parent"
android:id="@+id/selectImageBtn"
android:layout_height="wrap_content"
android:text="选择图片"
/>
<Button android:layout_width="fill_parent"
android:id="@+id/cutImageBtn"
android:layout_height="wrap_content"
android:text="选择图片进行裁剪"
/>
<!-- 用于显示图片的信息 -->
<ImageView android:>
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>