这是一些我不明白的 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 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/