Java Android-用加载动画替换跳过帧
我有一个跳过帧的问题,在一个真实的设备上大约是90-110帧,但在模拟器上只有20-30帧。 我遇到了这个问题,因为我在一个活动中有5个片段,每个片段都有15-30个按钮,它们是线性布局,因为我需要在一个按钮中有两个图片和文本视图,这似乎是一种方法 这就是它跳过帧的原因,我需要在它打开活动之前等待几秒钟 这看起来不太好,因为我不能在片段中有更少的数据,所以我决定创建加载动画 但问题是,每当我创建它时,在YouTube或StackOverflow上的各种教程之后,加载动画只在活动打开时出现,然后就没有任何用处了 有人知道解决办法吗 活动xmlJava Android-用加载动画替换跳过帧,java,android,android-layout,android-studio,Java,Android,Android Layout,Android Studio,我有一个跳过帧的问题,在一个真实的设备上大约是90-110帧,但在模拟器上只有20-30帧。 我遇到了这个问题,因为我在一个活动中有5个片段,每个片段都有15-30个按钮,它们是线性布局,因为我需要在一个按钮中有两个图片和文本视图,这似乎是一种方法 这就是它跳过帧的原因,我需要在它打开活动之前等待几秒钟 这看起来不太好,因为我不能在片段中有更少的数据,所以我决定创建加载动画 但问题是,每当我创建它时,在YouTube或StackOverflow上的各种教程之后,加载动画只在活动打开时出现,然后就
<?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>
您可以查看Android新材质设计库中添加的品牌发布主题,用于防止应用程序冷启动,并可以替换加载动画 您可以在XML中插入一个布局(例如带有背景色和微调器的RelativeLayout
),该布局占据所有屏幕大小。当你加载完片段后,将布局的可见性设置为Gone
对不起,我是Android新手,你能一步一步地教我吗?我使用RelativeLayout作为根元素创建新布局资源文件?然后设置背景色并将进度条放入其中?或者一些定制的微调器?然后呢?发布你活动的XML在第一篇文章中提到