我有一個跳幀的問題,在一個真正的設備上,大約90-110幀,但在模擬器上它只有20-30。 我有這個問題,因爲我有一個活動內的5個片段,每個片段都有15到30個按鈕,它們是LinearLayouts,因爲我需要在一個按鈕中放置兩個圖片和TextView,這似乎是一種方法。Android - 用加載動畫替換跳過的框架
這就是它跳過幀的原因,我需要等待幾秒鐘才能打開活動。
這看起來不太好,因爲碎片中的數據量不足,我決定創建加載動畫。
但問題是,無論何時創建它,遵循YouTube或StackOverflow上的各種教程,只有在活動打開時纔會出現加載動畫,然後就沒有用處。
有誰知道解決方案?
活動XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="hr.app.liftme.liftmehr.Vjezbe">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
android:elevation="0dp"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.AppBarOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_vjezbe" />
</android.support.design.widget.CoordinatorLayout>
內容的XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="0dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="hr.app.liftme.liftmehr.Vjezbe"
tools:showIn="@layout/activity_vjezbe"
android:id="@+id/loadingPanel">
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Vježbe"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
app:tabMode="scrollable"
app:tabGravity="fill"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewPager"
android:background="#ffffff">
</android.support.v4.view.ViewPager>
</android.support.design.widget.AppBarLayout>
</LinearLayout>
這並沒有解決我的問題,但無論如何感謝 – DaxHR