Android 在内容中使用边框缩放ImageView

Android 在内容中使用边框缩放ImageView,android,android-layout,android-studio,imageview,Android,Android Layout,Android Studio,Imageview,是否可以在Android中缩放ImageView而不扭曲图像 这是图像: 我想这样缩放(不扭曲边界): 你可以做两件事: 1]使用9个补丁图像: 这将在9面片图像中使用您的图像和变换。这样,该部分的边框将仅位于视图内部,而不是边框 2] 为那件事做准备。。 -您可以使用两个drawble,并将其作为单个单元使用。为此 就像:: 对于正方形,简单地说: 名称::square.xml位于可绘制文件夹中 <shape xmlns:android="http://schemas.and

是否可以在Android中缩放ImageView而不扭曲图像

这是图像:

我想这样缩放(不扭曲边界):
你可以做两件事:

1]使用9个补丁图像:

这将在9面片图像中使用您的图像和变换。这样,该部分的边框将仅位于视图内部,而不是边框

2] 为那件事做准备。。 -您可以使用两个drawble,并将其作为单个单元使用。为此

就像::

对于正方形,简单地说:

名称::
square.xml
位于可绘制文件夹中

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <solid android:color="@color/line_color" />
</shape>

对于底部的三角形::您可以直接将图像用于

假设其名称为triangle.png

那么对于最终布局:

 <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="@dimen/margin_8">

    <ImageView
        android:layout_gravity="bottom"
        android:layout_width="@dimen/margin_20"
        android:layout_height="@dimen/margin_20"
        android:src="@drawable/triangle" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/square"
        android:orientation="vertical"
        android:padding="@dimen/margin_normal">

        <TextView
            android:id="@+id/tvMyMessage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="false"
            android:text="Is it possible scale an ImageView in Android without distort the image?Is it possible scale an ImageView in Android without distort the image?Is it possible scale an ImageView in Android without distort the image?Is it possible scale an ImageView in Android without distort the image?"
            android:padding="5dp"
            android:gravity="start"
            android:textColor="@color/black_title" />
    </LinearLayout>
</LinearLayout>

如果需要更多帮助,请告诉我