2

I have a shape. I am using a random color to fill the shape.

enter image description here

I have an image which needs to be set for the background of this shape. (I am just thinking it should be background. May be I am using wrong words. )

Result should be something like this (note the image at the background).

enter image description here

Azizjon Kholmatov
  • 1,136
  • 1
  • 13
  • 26

4 Answers4

0

I recommend you that library which you can custom corners , shape and other things and then you can put your image view inside it and then you'll have your view

here is the link https://github.com/florent37/ShapeOfView

Ahmed Jamal
  • 216
  • 1
  • 5
  • I'm using it and it's working well with me what is the issue is appearing to you – Ahmed Jamal Jun 25 '19 at 19:07
  • I used to library as they instructed in Github, but there is no change at all. The code compiles but nothing changes. I just see the rectangles only. None of the effects/shape changes offered by this library is working. I have no idea what is the issue. – Azizjon Kholmatov Jun 29 '19 at 10:24
0

You can set src of your image view to those white things you have, then you will have your shape as background and this pattern on it as well. use android:src

0

I came across with this library. RoundedImageView Github link

All I needed to do was:

<com.makeramen.roundedimageview.RoundedImageView
        android:layout_width="0dp"
        android:layout_height="200dp"
        android:src="@drawable/add_card_head_bg"
        android:scaleType="centerCrop"
        app:riv_corner_radius="90dip"
        app:riv_mutate_background="true"
        app:riv_corner_radius_bottom_left="50dp"/>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Azizjon Kholmatov
  • 1,136
  • 1
  • 13
  • 26
0

If you want to show an image within a shape, Try this,

shape.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/colorPrimaryDark"/>
    <corners android:bottomLeftRadius="56dp"/>
</shape>

Now set the shape for a layout, then add the image that you want in image view then adjust the alpha value to show both shape and image,

layout.xml

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="120dp"
    android:background="@drawable/shape">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/blue_image"      
        android:alpha=".2"/>
</RelativeLayout>

Output will be like this

Hope this will help.