将活动更改为AppCompatActivity会占用更多RAM吗?

时间:2016-03-20 09:06:30

标签: android android-activity memory android-appcompat

我们的应用在登录后立即占用最多60MB(MainActivity执行setContentView(R.layout.mainActivity);时)

最近我们将活动更新为AppCompatActivity。我注意到这个改变增加了大约30MB的RAM(该应用程序现在在登录后立即占用90MB RAM。)

我通过回复Activity并确认内存减少来确认这一点。

为什么会这样?这是否意味着我在使用AppCompatActivity时做错了什么?

我还尝试将所有UI组件更改为AppCompat(TextViewAppCompatTextViewImageViewAppCompatImageView等等。)但我没有看到任何差异。

任何建议都将不胜感激。

修改

添加MainActivity的布局xml:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainActivity"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/background"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:padding="15dip" >

    <ImageButton
        android:id="@+id/selectContactBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="contacts"
        android:src="@drawable/select_contact_enabled"
        android:textSize="18sp"
        android:layout_above="@+id/selectMediaBtn"
        android:layout_alignRight="@+id/selectMediaBtn"
        android:layout_alignEnd="@+id/selectMediaBtn" />

    <TextView
        android:id="@+id/destName"
        android:layout_width="175dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/CallNumber"
        android:layout_alignLeft="@+id/CallNumber"
        android:layout_alignStart="@+id/CallNumber"
        android:layout_alignRight="@+id/CallNumber"
        android:layout_alignEnd="@+id/CallNumber"
        android:textStyle="bold" />

    <ImageButton
        android:id="@+id/selectMediaBtn"
        android:layout_width="300dp"
        android:layout_height="220dp"
        android:contentDescription="mypic"
        android:clickable="true"
        android:src="@drawable/mediaicon"
        android:textSize="18sp"
        android:layout_above="@+id/CallNow"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <ImageButton
        android:id="@+id/inviteButton"
        android:layout_width="300dp"
        android:layout_height="220dp"
        android:contentDescription="invite "
        android:clickable="false"
        android:src="@drawable/invite"
        android:textSize="18sp"
        android:layout_above="@+id/CallNow"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:visibility="invisible" />

    <AutoCompleteTextView
        android:id="@+id/CallNumber"
        android:layout_width="175dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:enabled="true"
        android:hint="To...."
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:phoneNumber="true"
        android:maxLength="10"
        android:singleLine="true"
        android:completionThreshold="1"
        android:inputType="textAutoComplete|text"
        android:layout_alignTop="@+id/selectContactBtn"
        android:layout_alignLeft="@+id/selectMediaBtn"
        android:layout_alignStart="@+id/selectMediaBtn"
        android:layout_alignRight="@+id/userStatusPositive"
        android:layout_alignEnd="@+id/userStatusPositive">

        <requestFocus />
    </AutoCompleteTextView>

    <Button
        android:id="@+id/CallNow"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:enabled="true"
        android:textSize="18sp"
        android:text="Call Now"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <ImageButton
        android:id="@+id/selectProfileMediaBtn"
        android:contentDescription="mypic"
        android:clickable="true"
        android:src="@drawable/avatar"
        android:layout_width="200dp"
        android:layout_height="120dp"

        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_above="@+id/CallNumber"
        android:layout_alignLeft="@+id/CallNumber"
        android:layout_alignStart="@+id/CallNumber"

        android:background="@android:color/transparent" />

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progressBar"
        android:layout_alignParentTop="true"
        android:layout_alignLeft="@+id/selectContactBtn"
        android:layout_alignStart="@+id/selectContactBtn"
        android:layout_marginTop="49dp" />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/clear"
        android:clickable="true"
        android:background="@drawable/clear"
        android:layout_alignBottom="@+id/CallNumber"
        android:layout_toRightOf="@+id/CallNumber"
        android:layout_toEndOf="@+id/CallNumber"  />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="RingTone Name "
        android:id="@+id/ringtoneName"
        android:visibility="invisible"
        android:background="@android:color/white"
        android:textColor="@android:color/black"
        android:singleLine="true"
        android:hint="No Ringtone Was Chosen !"
        android:layout_above="@+id/CallNow"
        android:layout_alignLeft="@+id/selectMediaBtn"
        android:layout_alignStart="@+id/selectMediaBtn"
        android:layout_alignRight="@+id/selectContactBtn"
        android:layout_alignEnd="@+id/selectContactBtn" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/userStatusPositive"
        android:layout_alignBottom="@+id/CallNumber"
        android:layout_alignTop="@+id/CallNumber"
        android:layout_alignRight="@+id/CallNow"
        android:layout_alignEnd="@+id/CallNow"
        android:layout_alignLeft="@+id/CallNow"
        android:layout_alignStart="@+id/CallNow"
        android:src="@drawable/positive"
        android:visibility="invisible" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/userStatusNegative"
        android:layout_alignBottom="@+id/CallNumber"
        android:layout_alignTop="@+id/CallNumber"
        android:layout_alignRight="@+id/CallNow"
        android:layout_alignEnd="@+id/CallNow"
        android:layout_alignLeft="@+id/CallNow"
        android:layout_alignStart="@+id/CallNow"
        android:src="@drawable/negative"
        android:visibility="invisible" />

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/fetchuserprogress"
        android:layout_alignBottom="@+id/CallNumber"
        android:layout_toLeftOf="@+id/clear"
        android:layout_alignTop="@+id/CallNumber"

        android:layout_alignRight="@+id/CallNumber"
        android:layout_alignEnd="@+id/CallNumber"

        android:layout_alignLeft="@+id/CallNow"
        android:layout_alignStart="@+id/CallNow"
        android:visibility="gone" />

    <ImageView
        android:layout_width="@dimen/sb__text_size"
        android:layout_height="@dimen/sb__text_size"
        android:id="@+id/mediaStatusArrived"
        android:layout_above="@+id/ringtoneName"
        android:layout_alignRight="@+id/selectMediaBtn"
        android:layout_alignEnd="@+id/selectMediaBtn"
        android:visibility="invisible"
        android:layout_marginRight="@dimen/sb__text_size"
        android:src="@drawable/doublepositive" />

    <ImageView
        android:layout_width="@dimen/sb__text_size"
        android:layout_height="@dimen/sb__text_size"
        android:id="@+id/ringtoneStatusArrived"
        android:visibility="invisible"
        android:layout_alignBottom="@+id/selectMediaBtn"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_marginRight="@dimen/sb__text_size"
        android:src="@drawable/doublepositive" />

</RelativeLayout>

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="#ffff"/>


</android.support.v4.widget.DrawerLayout>

0 个答案:

没有答案