7...">

View Cropped 1080 x 1920 phones

In my project, the user view has a fixed width. Width shown in values ​​-> dimen

<dimen name="layout_width">75dp</dimen>

The problem is that on some device (for example, Pixel) with a resolution of 1080 X 1920, this image is cropped. However, some other devices (for example: Pixel2) with the same resolution all work fine.

Tried to use different sized files, as in this post. Both of these devices are selected from the same size files.

the code

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="21dp"
    android:gravity="center"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="55dp"
        android:layout_height="55dp"
       >

        <ImageView
            android:id="@+id/icon"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_centerInParent="true"
            tools:background="@drawable/icon" />
    </RelativeLayout>

    <TextView
        android:id="@+id/title"
        android:layout_width="75dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical|center_horizontal"
        android:layout_marginTop="20dp"
        android:gravity="center"
        />
</LinearLayout>
+4
source share
2 answers

Inside your imageView, experiment with different scaleTypes to see if your use case is appropriate.

    <ImageView
        android:id="@+id/icon"
        android:layout_width="35dp"
        android:layout_height="35dp"
        android:layout_centerInParent="true"
        android:scaleType="fitCenter"
        tools:background="@drawable/icon" />

scaleType: FIT_XY, FIT_START, FIT_CENTER, FIT_END, CENTER, CENTER_CROP

+1

- . 1080 * 1960 v/s nexus 5x ( )

Samsung S6 ( dpi, 577 xxxhdpi).

, , wrap_content match_parent

+1

Source: https://habr.com/ru/post/1692684/


All Articles