【发布时间】:2020-02-12 21:45:48
【问题描述】:
我正在尝试在初始屏幕上显示背景图像和进度条。
splash.xml 的代码
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:layout_height="match_parent" android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" android:background="@drawable/spalsh">
<ProgressBar
android:id="@+id/loading"
style="?android:progressBarStyleLarge"
android:layout_width="wrap_content"
android:indeterminateDrawable="@layout/progressbartemplate"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="10dp" />
</FrameLayout>
然后我有样式
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:background" >@layout/splash</item>
</style>
然后我将这个样式应用到manifiestfile中的Activity
<activity
android:name="com.test.SplashActivity" android:theme="@style/SplashTheme"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
但是当应用程序启动时,我看不到图像和进度条,而我可以在设计视图中看到。 如果我使用 Layer-List 并删除进度条,相同的代码将起作用。
有人可以建议我如何在底部显示带有进度条的 bg 图像吗?
提前致谢
【问题讨论】:
-
如果您有专门的启动活动,则将进度放入其 layout.xml 文件并显示特定时间,然后完成活动
-
还可以查看this 以了解不同的显示方式
-
@MohammedAlaa 如果我使用活动的布局来显示启动画面,那么当他第一次点击应用程序启动它时,用户可以看到一段时间的空白屏幕。
-
@Paven Tiwari 是的,你是对的,但你正在做的是你需要将 xml 布局文件作为背景,对吗?我不知道这是否可行,因为你怎么能膨胀这个布局并且活动还没有开始?
-
@MohammedAlaa 正如我在问题中提到的,“如果我使用图层列表并删除进度条,相同的代码将起作用。”我想知道为什么
标签: android android-layout android-activity splash-screen android-theme