Android - 自定义标题栏渐变问题

发布于 2024-12-19 21:48:07 字数 520 浏览 4 评论 0 原文

我想创建一个自定义渐变和将其应用到 LinearLayout 的背景。

以下是渐变代码:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <gradient
      android:startColor="#31527B"
      android:endColor="#20426F"
      android:angle="270"/>
</shape>

我需要如下所示的渐变:

在此处输入图像描述

不知怎的,我没有得到这种效果。我在角度等方面做错了什么/我需要对渐变应用更多属性吗?

I want to create a custom gradient & apply it to the background of a LinearLayout.

Here is code for the gradient:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <gradient
      android:startColor="#31527B"
      android:endColor="#20426F"
      android:angle="270"/>
</shape>

I need a gradient as the one below:

enter image description here

Somehow I'm not getting this effect. Am I doing something wrong in terms of angle etc / do I need to apply some more attributes to gradient?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文