简体   繁体   中英

ImageView is not adjusting according to screen size

My filter image in toolbar is going out of screen for small width phones but it's working properly for pixel2 like phones.

Screenshot

在此处输入图像描述

xml code

       <ImageView
            android:layout_width="30dp"
            android:layout_height="50dp"
            android:src="@drawable/filter1"
            android:layout_toEndOf="@id/imageView7"
            android:layout_marginStart="310dp"
            android:layout_marginEnd="20dp"/>

It is in Relativelayout.

Please solve my problem.

put your image in RelativeLayout and use align_parent :

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    <ImageView
          android:layout_width="30dp"
          android:layout_height="50dp"
          android:src="@drawable/filter1"
          android:layout_alignParentRight="true"
          android:layout_alignParentTop="true"
          android:layout_marginEnd="20dp"/>

</RelativeLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM