Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to set an imageview in the corner of card view

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my android app with kotin, in one of my interface, a recyclerview that contains a grid of cardview. In evrey items in the grid, i want to make an imageview in he corner of the cardview .
The following code is belong to the item :

So, how can i set this imageview in the corner of cardview at the bottom in right as the following photo
?

11.png
[Thumbnail for 11.png]
 
Ranch Foreman
Posts: 375
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try with ConstraintLayout ?
 
Maha Sakka
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
with constraintLayout could i put the imageview in the corner as the image above ?
 
Randy Tong
Ranch Foreman
Posts: 375
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course you can. You can achieve that with RelativeLayout too.
 
Maha Sakka
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made some changes, here's the new code:

But, the imageview is still inside the cardview, not in the corner as the image above
 
Maha Sakka
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to put my imageview as the following image
12.png
[Thumbnail for 12.png]
 
Randy Tong
Ranch Foreman
Posts: 375
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your gradle file too
 
Maha Sakka
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's my gradle file :

 
Randy Tong
Ranch Foreman
Posts: 375
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your gradle file too
 
Maha Sakka
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have already posted above
 
Randy Tong
Ranch Foreman
Posts: 375
4
Android Tomcat Server Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use two RelativeLayout to achieve. First is for whole layout, and the second is for CardView.


Note that I have set a negative layout_marginTop to imageView, so that imageView can overlap on cardView.

And here the result

 
Maha Sakka
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, that exactly what i want.
 
Randy Tong
Ranch Foreman
Posts: 375
4
Android Tomcat Server Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!