dancingbush
dancingbush

Reputation: 2281

What would cause this XML to use up memory

I have a scrollveiw root layout wrapping a Relative layout with some Imageviews, textviews etc. For some reason when accessing this XML file it uses up large amounts of heap space. Have addressed all lint erros but still have issues, here is the code:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_app"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    >

    <RelativeLayout 
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:id="@+id/image_wrapper"
      >

        <!-- First Ad -->



        <!-- Top Notes -->

        <TextView
            android:id="@+id/tv_testSelected_TopNotes"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:layout_marginTop="20dp"
            android:text="@string/sample_notes"
            android:textColor="#c4c4c4" />

        <!-- white line splittong widgets -->
        <ImageView
            android:id="@+id/splitter"
            android:contentDescription="@string/splitter"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tv_testSelected_TopNotes"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:src="@drawable/splitter" />

        <!-- Section 1 Displine and Test Name and default displine specific image -->

        <TextView
            android:id="@+id/tv_testSelected_Displine"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/tv_testSelected_TopNotes"
            android:layout_below="@+id/splitter"
            android:layout_marginTop="30dp"
            android:text="Haematology"
            android:textColor="#55bbfa"
            android:textSize="20sp" />

        <!-- test name -->

        <TextView
            android:id="@+id/tv_setelectedTest_TestName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/tv_testSelected_Displine"
            android:layout_alignBottom="@+id/tv_testSelected_Displine"
            android:layout_marginLeft="15dp"
            android:layout_toRightOf="@+id/tv_testSelected_Displine"
            android:text="TEST"
            android:textColor="#FFFFFF"
            android:textSize="20sp" />

        <!-- displine specific image1_image -->
        <ImageView
            android:id="@+id/iv_selectedTest_TestImage"
            android:contentDescription="@string/imagedescription"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tv_testSelected_Displine"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="5dp"
            android:adjustViewBounds="true"
            android:scaleType="fitXY"
            android:src="@drawable/image1" />

        <!-- Phone NUmber and Call -->


         <TextView
            android:id="@+id/tv_selectedTest_MainText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/iv_selectedTest_TestImage"
            android:layout_marginTop="20dp"
            android:text="Comments: "
            android:textColor="#c4c4c4" />

         <!-- orginal number text view was here-->
         <TextView
            android:id="@+id/tv_selectedTest_PhoneNumber"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/iv_selectedTest_TestImage"
            android:layout_toRightOf="@+id/tv_selectedTest_MainText"
            android:layout_alignTop="@+id/tv_selectedTest_MainText"

            android:text="Number "
            android:textColor="#55bbfa"
            android:textSize="20sp" />



          <!-- Section 2 contains test tube image and tanle with details-->

    <LinearLayout
         android:id="@+id/tv_selectedTest_Section2"
         android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_below="@+id/tv_selectedTest_PhoneNumber" >




<!--test tube image-->

        <ImageView
            android:id="@+id/image2_selectedTest_Tubes"
            android:contentDescription="@string/imagedescription"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:adjustViewBounds="true"
            android:scaleType="fitXY"
            android:src="@drawable/image2" />

        </LinearLayout>
<!--end section 2-->         




         <!-- Table with lots of details -->

         <TableLayout 
             android:id="@+id/testSelcted_tabl"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tv_selectedTest_Section2"
        android:layout_marginTop="20dp" 
        android:layout_marginRight="10dp"
        android:layout_marginLeft="5dp"

             >

             <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="3" >

            <TextView
                android:id="@+id/tvTable_TAT"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/cell_shaoe"
                android:padding="5dp"
                android:typeface="sans"
                android:text="TAT (hrs)"
                 android:textColor="#FFFFFF"
                android:textAppearance="?android:attr/textAppearanceMedium" >
            </TextView>

            <TextView
                android:id="@+id/tvTable_TATText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:background="@drawable/cell_shaoe"
                android:typeface="sans"
                android:ems="10"
                android:hint="Hours"
                android:padding="5dp"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>


             <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="3" >

            <TextView
                android:id="@+id/tvTable_Fixation"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/cell_shaoe"
                android:padding="5dp"
                android:typeface="sans"
                android:text="Fixation"
                android:textColor="#FFFFFF"
                android:textAppearance="?android:attr/textAppearanceMedium" >
            </TextView>

            <TextView
                android:id="@+id/tvTFixation_Input"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:background="@drawable/cell_shaoe"
                android:typeface="sans"
                android:ems="10"
                android:hint="Histology"
                android:padding="5dp"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>
              <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="3" >

            <TextView
                android:id="@+id/tvTable_TATUrgent"
                android:layout_width="110dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/cell_shaoe"
                android:padding="5dp"
                android:typeface="sans"
                android:text="Urgent"
                android:textColor="#FFFFFF"
                android:textAppearance="?android:attr/textAppearanceMedium" >
            </TextView>

            <TextView
                android:id="@+id/tvTable_TATUrgetInput"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:background="@drawable/cell_shaoe"
                android:typeface="sans"
                android:ems="10"
                android:hint="Hours        "
                android:padding="5dp"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>


              <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="3" >

            <TextView
                android:id="@+id/tvTable_TestCode"
                android:layout_width="110dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/cell_shaoe"
                android:padding="5dp"
                android:typeface="sans"
                android:text="Test Code"
                android:textColor="#FFFFFF"
                android:textAppearance="?android:attr/textAppearanceMedium" >
            </TextView>

            <TextView
                android:id="@+id/tvTable_TestCode_Input"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="2"
                android:background="@drawable/cell_shaoe"
                android:typeface="sans"
                android:ems="10"
                android:hint="Code        "
                android:padding="5dp"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>
               <TableRow
            android:id="@+id/tableRow5"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="3" >

            <TextView
                android:id="@+id/tvTable_Refeeral_Center"
                android:layout_width="110dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/cell_shaoe"
                android:padding="5dp"
                android:typeface="sans"
                android:text="Referral Lab"
                android:textColor="#FFFFFF"
                android:textAppearance="?android:attr/textAppearanceMedium" >
            </TextView>

            <TextView
                android:id="@+id/tvTable_Referral_Center_Input"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_weight="2"
                android:background="@drawable/cell_shaoe"
                android:typeface="sans"
                android:ems="10"
                android:hint="Hours        "
                android:padding="5dp"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>

               <TableRow
            android:id="@+id/tableRow6"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:weightSum="3" >

            <TextView
                android:id="@+id/tvTable_RefRanges"
                android:layout_width="110dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/cell_shaoe"
                android:padding="5dp"
                android:typeface="sans"
                android:text="Ref Ranges"
                android:textColor="#FFFFFF"
                android:textAppearance="?android:attr/textAppearanceMedium" >
            </TextView>

            <TextView
                android:id="@+id/tvrefRanges_Input"
                android:layout_width="wrap_content"
                android:layout_height="50dp"
                android:layout_weight="2"
                android:background="@drawable/cell_shaoe"
                android:typeface="sans"
                android:ems="10"
                android:hint="Ref Range"
                android:padding="5dp"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>
         </TableLayout>


         <!-- bottom panel with like button and number to ring and nack button -->

         <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="@dimen/height"
    android:layout_below="@+id/testSelcted_tabl"
    android:layout_marginTop="30dp"
     android:background="@color/dark_purple" >

    <LinearLayout
        android:id="@+id/line"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="@dimen/divider_size"
        android:layout_alignParentBottom="true"
        android:background="@color/dark_blue" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/line" >

        <ImageButton
            android:id="@+id/btnImg_Back"
            android:layout_width="@dimen/width"
            android:layout_height="fill_parent"
            android:background="@drawable/ui_button_blue"
            android:src="@drawable/ico_left" />

        <LinearLayout
            android:layout_width="@dimen/divider_size"
            android:layout_height="fill_parent"
            android:background="@color/dark_blue" >
        </LinearLayout>

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="0dip"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:tag="bold"
            android:text="@string/txt_some_header"
            android:textColor="@color/white"
            android:textSize="@dimen/tex_size_xxlarge" />

        <LinearLayout
            android:layout_width="@dimen/divider_size"
            android:layout_height="fill_parent"
            android:background="@color/dark_blue" >
        </LinearLayout>

        <ImageButton
            android:id="@+id/btnImg_Like"
            android:layout_width="@dimen/width"
            android:layout_height="fill_parent"
            android:background="@drawable/ui_button_blue"
            android:src="@drawable/ico_like" />
    </LinearLayout>
</RelativeLayout>

         <!-- End bottom of blue tab layout -->








         <!-- End top level relative layout -->
</RelativeLayout>
</ScrollView>

Any input appreciated. Ciaran

Upvotes: 0

Views: 48

Answers (1)

nKn
nKn

Reputation: 13761

Your layout file seems to be that large that it's probably making increase heap usage just by that fact. But if I had to point to the culprit, I'd choose your ImageViews. Bear it mind that when you load this layout file, all the ImageViews will render, and if your image files are not optimized, an incremented heap usage might occur.

I recommend reading this reference page, as you'll be able to confirm or discard this idea as the culprit:

Upvotes: 1

Related Questions