【发布时间】:2011-05-07 19:22:01
【问题描述】:
这里有一些我不明白的 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>
背景代码:(两者代码相同,除了颜色)
<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 视图模式下可以正常工作,但在其他版本上不行)
【问题讨论】:
-
如果你提供了 xml 来让 drawable 不工作真的会更好。另外,您是否尝试过为两个框架布局使用相同的 black_to_white 背景?
标签: android background gradient shape