Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
缩放图像以适应android ImageView中的顶部和右侧_Android_Imageview_Image Scaling - Fatal编程技术网

缩放图像以适应android ImageView中的顶部和右侧

缩放图像以适应android ImageView中的顶部和右侧,android,imageview,image-scaling,Android,Imageview,Image Scaling,我使用ImageView,我希望源图像适合顶部和右侧 FitEnd缩放适合底部和右侧 所有其他的scaleenum也没有多大帮助 有什么想法吗 谢谢试试这段代码 <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="top|right"> <ImageView android:scaleT

我使用
ImageView
,我希望源图像适合顶部和右侧

FitEnd缩放适合底部和右侧 所有其他的scale
enum
也没有多大帮助

有什么想法吗

谢谢

试试这段代码

<LinearLayout
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:gravity="top|right">
   <ImageView
       android:scaleType="fitEnd"
       android:adjustViewBounds="true" />
</LinearLayout>


这应该可以得到预期的结果。

我相信您正在寻找fitStart,或者在代码中,
setScaleType(ImageView.ScaleType.FIT\u START)


使用它,您可以简单地将图像包装在一个向右对齐的布局包装器中,例如一个带有
android:layout\u alignParentRight=“true”

的RelativeLayout,只需使用scaleType=MATRIX即可

e、 g:



这是一个糟糕的答案,因为该代码是零碎的(双引号的使用不一致),而且简短的解释性段落几乎没有提供什么启发。@CarlosP我想你忘了读它是一个psuedo代码。我不相信填鸭式的回答,希望对方能做出一些努力。
<ImageView
    android:layout_width="%wanted width%"
    android:layout_height="%wanted height%"
    android:scaleType="matrix"
    android:src="%your src%" />