2. 将png确定为背景或形成Xml的形状:
创建xml文档——请将其称为“梯度-后方”
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:startColor="#ff0000ff"
android:endColor="#00ffffff"/>
<corners android:radius="10dp" />
</shape>
改变你想要的黑色价值。
并将之作为背景添加到您的观点小组,例如: LinearLayout:
android:background="@drawable/gradient_background"
EDIT:
To achieve what you mentioned in your comment, that the gradient height should stay fixed while positioned at the bottom, but the white area can stretch vertically, I suggest you use a nine-patch which you can create with the Draw Nine Patch Tool. Launch the tool from your SDK s tools folder - click the nine-patch bat file (and wait a while for it to launch, then import your png). You then draw black lines along the sides of your image to define which parts can be stretched, name the file something.9.png and reference it as background in your ViewGroup. Please see the linked-to documentation for details.