adding image in layout_gravity but doesn't work

I wanna put my logo to my app and layout_gravity doesn't work, neither found in Android Studio why? maybe there is another option for this, maybe by version i don't know, below I share the code in XMl.

<ImageView
   android:layout_gravity="center"
   android:layout_width="140dp"
   android:layout_height="140dp"
   android:src="@drawable/logo" />

Upvotes: 0

Views: 141

Answers (1)

myst
myst

Reputation: 51

if you using parent layout <RelativeLayout> and try android:centerInParent="true" or android:layout_centerVertical="true" (center vertical) , android:layout_centerHorizontal="true" (center horizontal) in <ImageView> and if you use parent layout <LinearLayout> try android:layout_gravity="center"

Upvotes: 1

Related Questions