Notification texts go here Contact Us Buy Now!

RecyclerView GridLayoutAdapter - How to center items

android:gravity="center"

With that line you already Center the ImageView horizontal and vertical.

If you just want one of them use for example:

android:gravity="center_horizontal"

I don't know what exactly is your Problem, we do not even know

android:layout_width="@dimen/custom_photo_item_size"

which value is declared in your dimensions.xml...

If you want to Center your whole Item you would Need to declare:

android:layout_gravity="Center"

but this doesn't make any sense as you only have one layout in a GridView-Cell and you declared your rootView of your Item as

android:width="match_parent"
android:height="match_parent"

So this is just an info for you ;)

Provide more Infos if you want better Support. Hope it helps anyway

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.