在Android中创建给定形状的图像视图 [英] Creating an Image view of given shape in android
本文介绍了在Android中创建给定形状的图像视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在Android中创建此特定形状的imageview.如果可以将图像裁剪成这种形状,那么也可以.请帮帮我吗?
I need to create an imageview of this particular shape in Android. If cropping an image in this shape is possible, then also its fine. Please help me out with it?
推荐答案
这将是完整的设置
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/gohan" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/triangle_shape" />
</FrameLayout>
triangle_shape.xml,它将位于您的
drawable
目录
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="-70" // you will have to tweak this a little for adjustment
android:pivotX="100%"
android:pivotY="75%"
android:toDegrees="40">
<shape android:shape="rectangle">
<stroke
android:width="10dp"
android:color="@android:color/transparent" />
<solid android:color="@android:color/holo_blue_bright" />
</shape>
</rotate>
</item>
</layer-list>
输出
这篇关于在Android中创建给定形状的图像视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文