gpt4 book ai didi

android - 底部布局的渐变形状背景

转载 作者:太空狗 更新时间:2023-10-29 14:31:48 27 4
gpt4 key购买 nike

这是一些我不明白的 UI 行为...

我想要的:

This is what I would like to achieve

我得到的:

This is real result

我的代码:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/black_to_white" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/blue_to_red" />
</LinearLayout>

背景代码:(两者的代码相同,颜色除外)

<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#000000"
android:endColor="#ffffff"
android:angle="270" />
</shape>

如何让我的第二个渐变从屏幕中间开始为蓝色?

(我注意到渐变在 android 3.0 View 模式下工作正常,但在其他版本上不工作)

最佳答案

我正在使用以下代码,它可以正常工作。

<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#151B8D"
android:endColor="#ff0000"
android:angle="270" />
</shape>

关于android - 底部布局的渐变形状背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5923447/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com