Home > Mobile >  How to center between layouts in relative layout
How to center between layouts in relative layout

Time:11-07

I want to place the cardview in the center of the ImageView like this:

enter image description here

If I use android:layout_below it will be like this:

enter image description here

This is my code:

enter image description here

CodePudding user response:

Please read how to write a good question first.

Regarding your question this bit of code might help you try with a negative value of translationY

for example:

android:translationY="-50dp"

CodePudding user response:

According to me, Rearranging the location of the layout, image or textview comes under the topic of alignment. so if you want to put your image src in middle vertically, you should use the code below written

android:layout_centerVertical="true"

and for center Horizontally

android:layout_centerHorizontal="true"

or else, I think we can also use gravity to put every element in mid of parent layout like android:gravity="center" Hoping that it will be helpful.

  • Related