Search code examples
androidandroid-layoutandroid-imageviewandroid-image

How to put a image in top and right?


How can I put a image on top and right of the screen? With android:layout_gravity="top|right" only works right. The image is on the bottom

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"     android:background="@drawable/image"
    android:layout_height="match_parent"
    android:orientation="vertical" android:gravity="bottom">

    <ImageView
        android:id="@+id/imageView1" android:layout_gravity="top|right"
        android:layout_width="100dp"  
        android:layout_height="100dp"
        android:src="@drawable/logo" />
</LinearLayout>

Solution

  • instead of android:gravity="bottom" , write android:gravity="top|right" to your outer LinearLayout