我那里有一个TextView
一个非常简单的应用程序和Button
内RelativeLayout
的(与背景图像):造成帧背景图像跳过
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:background="@drawable/background_image" >
<!-- text in top left of background -->
<TextView android:text="App" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- primary button that outputs audio -->
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:onClick="trueButtonClick" />
</RelativeLayout>
的onClick
事件只是播放一些音频:
public void trueButtonClick(View v) {
//create media player
MediaPlayer mp = MediaPlayer.create(this, R.raw.audio_test);
//make noise
mp.start();
}
在logcat中,我得到的消息:
03-02 23:41:40.063 1910-1910/com.example.mohammad.trueapp E/MediaPlayer﹕ Should have subtitle controller already set
03-02 23:41:40.063 1910-1910/com.example.mohammad.trueapp I/Choreographer﹕ Skipped 210 frames! The application may be doing too much work on its main thread.
03-02 23:41:43.961 1910-1910/com.example.mohammad.trueapp I/Choreographer﹕ Skipped 232 frames! The application may be doing too much work on its main thread.
03-02 23:45:05.506 1910-1910/com.example.mohammad.trueapp I/Choreographer﹕ Skipped 115 frames! The application may be doing too much work on its main thread.
03-02 23:45:07.279 1910-1910/com.example.mohammad.trueapp E/MediaPlayer﹕ Should have subtitle controller already set
03-02 23:45:07.323 1910-1910/com.example.mohammad.trueapp I/Choreographer﹕ Skipped 108 frames! The application may be doing too much work on its main thread.
03-02 23:45:10.490 1910-1910/com.example.mohammad.trueapp E/MediaPlayer﹕ Should have subtitle controller already set
当我删除背景图像@drawable/background_image
时,应用程序加速。但是,在添加背景图像之后,应用程序非常缓慢,从用户的角度来看似乎很糟糕。背景图像大小为1040x851。有没有一种方法可以加快速度以防止严重滞后?
没有你添加的硬件在AndroidManifest文件加速=真的吗? – Rustam 2015-03-03 04:54:38
@Rustam我刚刚做到了。没有太大的区别。另外,据我所知,这对老款Android手机无效。 – 2015-03-03 05:08:42
您是否在'drawable-?dpi'文件夹中针对不同分辨率缩放了图像?这将优化图像加载。 – Lamorak 2015-03-03 07:15:38