私の主な活動は主にボタンとして使われるイメージで構成されています。画像は適切なサイズに縮小されます。Percent Relative Layout
イメージ重いサムスンGS7ではMainActivityが遅れますが古代の電話ではありません
画像自体は、ドロウアブルフォルダ内の.pngファイルです。彼らは私が仮定しているものそれぞれ約120〜140キロバイトは、彼らの圧縮形式です。
これは、一度に画面上のあまりにも多くの画像と関連があると思っていましたが、私のサムスンGS7の画面のサイズの3分の1のデバイスにロードすると、遅れを最小限に抑えてlogcatはほとんどすべてのフレームレートをスキップします。
現在の理論では、おそらく高解像度の画面がリソースを増やしていると考えられますが、GS7のメモリは古いデバイスを矮小化するはずです。
そして、エミュレータはゴミのように走ります。どの物理デバイスよりも100倍遅いので、私はそれを気にしません。
唯一のことは、それぞれImageView
のonClickListener
です。このページでは他の作業は行われていません。
XML
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/abc"
android:textSize="27sp"
android:id="@+id/textMainTitle"
android:layout_gravity="center"
android:layout_alignParentTop="true"
android:textColor="#ffffff"
android:gravity="center_horizontal" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="def"
android:id="@+id/textMainSubTitle"
android:layout_gravity="center_horizontal"
android:layout_below="@id/textMainTitle"
android:gravity="center_horizontal" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/btn1"
android:src="@drawable/1"
app:layout_widthPercent="33%"
android:layout_below="@id/textMainSubTitle"
android:adjustViewBounds="true"
/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/btn2"
android:src="@drawable/2"
app:layout_widthPercent="33%"
android:layout_below="@id/textMainSubTitle"
android:layout_toRightOf="@id/btn1"
android:adjustViewBounds="true"
/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/btn3"
android:src="@drawable/3"
app:layout_widthPercent="33%"
android:layout_below="@id/textMainSubTitle"
android:layout_toRightOf="@id/btn2"
android:adjustViewBounds="true"
/>
// Other buttons removed. But there are six rows each with
// 3 button as there are above
関連するJava
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
btn1 = (ImageView) findViewById(R.id.btn1);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getApplicationContext(), activity1.class));
}
});
btn2 = (ImageView) findViewById(R.id.btn2);
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getApplicationContext(), activity2.class));
}
});
btn3 = (ImageView) findViewById(R.id.btn3);
btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getApplicationContext(), activity2.class));
}
});
//As in the XML layout, all other buttons have been removed for visual
Logcat
I/Choreographer: Skipped 31 frames! The application may be doing too much work on its main thread.
I/Choreographer: Skipped 38 frames! The application may be doing too much work on its main thread.
//and so on.
アドバイスや援助をいただければ幸いです。ありがとう
ご回答いただきありがとうございます。私は離れて引っ張られたが、私は戻ってupvote /コメント/マークasap – BR89