【问题标题】:splash screen and gradient闪屏和渐变
【发布时间】:2016-03-05 12:34:09
【问题描述】:

这是我的痛点。我是 android 开发新手,我想为应用程序创建启动画面。目前,在这个论坛中搜索后,我找到了从图片中实现启动画面的方法,但这不是我想要的。我希望启动画面是具有不同渐变的颜色。这个问题附有一张图片来说明我的意思。 不幸的是,由于我的声誉点低,无法粘贴图像。尽管如此,这是一个渐变图像的link。 进一步解释,我希望通过 java 或 xml 代码动态生成颜色,这样我就不必担心不同的屏幕尺寸,因为我所要做的就是为全屏显示生成所有内容。如果可能的话,我要避免使用图片资源。 帮助请。谢谢

【问题讨论】:

  • 如果您显示用于显示初始屏幕图像的代码并询问“如何更改它以显示渐变?”,您可能会得到更好的答案

标签: android gradient splash-screen


【解决方案1】:

创建一个形状,将其添加到可绘制对象中,例如:<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="@color/gradient_start" <!--this first color --> android:endColor="@color/gradient_end" <!--this second color --> android:angle="-270" /> <!--gradient angle --> </shape>

然后在你的 splash.xml 背景上,将背景设置为形状

添加

<LinearLayout
    android:id="@+id/ranking_order"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/list_grad"
    />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-30
    • 1970-01-01
    • 1970-01-01
    • 2011-11-04
    • 2018-12-11
    • 2010-09-14
    • 1970-01-01
    相关资源
    最近更新 更多