首页 > 解决方案 > 从特定位置剪切图像

问题描述

我的水平回收器视图中有以下行项目-

在此处输入图像描述

如您所见,我从服务器获得的项目很广泛。我想要的是将图像宽度削减一些值,但我希望从线条开始的位置到图像的右端进行切割。

这是我的 XML -

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="303dp"
    android:layout_height="80dp">

    <android.support.v7.widget.CardView
        android:id="@+id/search_image_contact_cardview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="5dp"
        app:cardCornerRadius="8dp">

        <ImageView
            android:id="@+id/vendorImageview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            tools:src="@mipmap/ic_launcher" />


    </android.support.v7.widget.CardView>


</android.support.constraint.ConstraintLayout>

我从服务器获得的原始图像是 303DP,我需要将其切成两半 - 从我画的线开始的位置开始切割,而不是从图像实际开始的位置开始切割。

我怎样才能实现这种行为?

标签: androidimageviewimage-scaling

解决方案


推荐阅读