效果图修改前:
image.png
效果图修改后:
image.png
orange_shape文件
android:shape="rectangle">
android:startColor="@android:color/holo_red_dark"
android:centerColor="@android:color/holo_green_dark"
android:endColor="@android:color/holo_blue_light"/>
布局layout
android:id="@+id/topView"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/orange_shape" />
activity(这种方案必须有设置shape后才能使用)
int[] colorsTwo = {Color.parseColor("#FFA538"),Color.parseColor("#FFC848"),Color.parseColor("#FFC848"),};
GradientDrawable backView = (GradientDrawable) view.getBackground();
backView.setColors(colorsTwo);
另外一种方案
int[] colors = {0xFFFF9326,0xFFFFC54E};
int[] colors = {Color.parseColor("#ffffff"),Color.parseColor("#ffffff")};
GradientDrawable drawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT,colors);
drawable.setCornerRadius(0);
view.setBackground(drawable);
有更好的实现方案,希望小伙伴给与文章参考连接或思路