Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 底部布局上的渐变形状背景_Android_Background_Gradient_Shape - Fatal编程技术网

Android 底部布局上的渐变形状背景

Android 底部布局上的渐变形状背景,android,background,gradient,shape,Android,Background,Gradient,Shape,下面是一些我不理解的UI行为 我想要的是: 我得到的是: 我的代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <FrameLa

下面是一些我不理解的UI行为

我想要的是:

我得到的是:

我的代码:

<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>

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


如何使第二个渐变从屏幕中间开始变为蓝色


(我注意到渐变在android 3.0的查看模式下运行良好,但在其他版本上不起作用)

我正在使用以下代码,它可以根据需要正常工作

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

问题是您的颜色代码中缺少alpha:

#[alpha][red][green][blue]

如果您为drawable不工作提供xml,那就更好了。另外,您是否已经尝试在两个框架布局中使用相同的黑白背景?
#[alpha][red][green][blue]