Faced such a problem. When ImageView appears in the xml markup, the activation starts to slow down. What could be the reason? Here is the markup itself:

 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/cameraBG" android:weightSum="0"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/cameraBG" android:weightSum="0"> <RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="horizontal" android:padding="15dp"> <ImageView android:layout_height="140dp" android:layout_width="140dp" android:id="@+id/image" android:src="@drawable/bgim"/> <TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:textColor="@color/white" android:text="@string/predPhoto" android:textSize="15dp" android:layout_alignTop="@+id/image" android:layout_toRightOf="@+id/image" android:layout_toEndOf="@+id/image" android:layout_marginTop="15dp" android:layout_marginLeft="15dp"/> </RelativeLayout> <RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:padding="15dp"> <TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:textColor="@color/white" android:textSize="18dp" android:text="@string/aboutPhoto" android:id="@+id/textAboutPhoto" android:layout_marginLeft="0dp" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/aboutPhoto" android:textColor="@color/white" android:layout_below="@+id/textAboutPhoto"/> <TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:textColor="@color/white" android:textSize="18dp" android:text="@string/category" android:layout_below="@+id/aboutPhoto" android:layout_marginTop="10dp" android:layout_marginLeft="0dp" android:id="@+id/textcheck"/> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="10dp" android:paddingLeft="20dp" android:paddingRight="20dp"> <TextView android:text="@string/categoryAnimal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15dp" android:textColor="@color/white"/> <CheckBox android:id="@+id/checkAnimal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-8dp" android:layout_marginLeft="4px" android:layout_marginRight="-7dp" android:layout_alignParentRight="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="10dp" android:paddingLeft="20dp" android:paddingRight="20dp"> <TextView android:text="@string/categoryFood" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15dp" android:textColor="@color/white"/> <CheckBox android:id="@+id/checkFood" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-8dp" android:layout_marginLeft="4px" android:layout_marginRight="-7dp" android:layout_alignParentRight="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="10dp" android:paddingLeft="20dp" android:paddingRight="20dp"> <TextView android:text="@string/categoryPeople" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15dp" android:textColor="@color/white"/> <CheckBox android:id="@+id/checkPeople" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-8dp" android:layout_marginLeft="4px" android:layout_marginRight="-7dp" android:layout_alignParentRight="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="10dp" android:paddingLeft="20dp" android:paddingRight="20dp"> <TextView android:text="@string/categoryTech" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15dp" android:textColor="@color/white"/> <CheckBox android:id="@+id/checkTech" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-8dp" android:layout_marginLeft="4px" android:layout_marginRight="-7dp" android:layout_alignParentRight="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="10dp" android:paddingLeft="20dp" android:paddingRight="20dp"> <TextView android:text="@string/categoryNature" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15dp" android:textColor="@color/white"/> <CheckBox android:id="@+id/checkNature" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-8dp" android:layout_marginLeft="4px" android:layout_marginRight="-7dp" android:layout_alignParentRight="true" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="10dp" android:paddingLeft="20dp" android:paddingRight="20dp"> <TextView android:text="@string/categorySelfie" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15dp" android:textColor="@color/white"/> <CheckBox android:id="@+id/checkSelfie" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-8dp" android:layout_marginLeft="4px" android:layout_marginRight="-7dp" android:layout_alignParentRight="true" /> </RelativeLayout> <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:paddingLeft="15dp" android:paddingRight="15dp" android:layout_marginTop="15dp" android:layout_marginBottom="15dp" android:orientation="vertical"> <Button android:layout_height="wrap_content" android:layout_width="match_parent" android:gravity="center" android:id="@+id/publicPhoto" android:background="@color/btnGrn" android:textColor="@color/white" android:textSize="18dp" android:text="@string/btnGrnFinish" /> </LinearLayout> </LinearLayout> </ScrollView> 
  • one
    Judging by the name bgim there is not a small picture. - KoVadim
  • In general, the idea is that the image path is programmatically transferred to the ImageView , which was received in another activity through the camera. Those. First, the camera activates, where after clicking on the button, a snapshot takes place, after which I get the path of the snapshot on the phone and transfer it to another activator, where I insert it into ImageView . Initially there is an image in it - this is bgim . As I understand it, it is best to crop the resulting image so as not to try to squeeze it entirely into the ImageView . - Amandi
  • If your ImageView size is 140x140, then you should not push a larger image into it. The user will not notice the improvements, and the brakes still like. - KoVadim
  • He came to the conclusion that it is necessary to cut - Amandi

1 answer 1

It can slow down due to the large size of the image file. Try to reduce it. It may also help to assign the image in the ImageView through the library for downloading and displaying images. For example, UIL or Picasso. I tried for this UIL and she helped to remove the lags, because assigns a picture outside the UI stream.