2016-01-13 24 views
2

enter image description hereandroid系统

创建给定形状的图像视图我需要建立在Android的这一特定形状的ImageView的。如果在这种形状裁剪图像是可能的,那么也是其罚款。请帮我拿出来吗?

+0

你需要做你的水平的定制供参考使用此链接https://github.com/siyamed/android-shape-imageview –

+0

和你尝试过什么?无线谷歌或任何东西? – user1140237

+0

是啊,我觉得@AnjaliTripathi是正确的,你可以看到在[机器人功能[根据图蒙ImageViews(https://github.com/siyamed/android-shape-imageview#bitmap-mask-based-imageviews)之一字形-imageview的](https://github.com/siyamed/android-shape-imageview)。所以,你应该做的是提供一个形状和整体的照片,然后你就可以得到你想要的图片。 –

回答

2

这将是一套完整的

<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> 

输出 gohan