Android 页面布局相关小记

自作多情 提交于 2019-12-06 12:30:19

1、设置渐变背景

<shape xmlns:android="http://schemas.android.com/apk/res/android"

    android:shape="rectangle">

    <gradient

        android:centerColor="#1FBDFF"

        android:endColor="#1FA5FF"

        android:startColor="#02EEFF"

        android:type="linear" />

</shape>

2、设置圆角渐变按钮

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 连框颜色值 -->

    <item>

        <shape>

            <corners android:radius="4dp" />

        </shape>

    </item>

    <!-- 主体背景颜色值 -->

    <item

        android:bottom="1dp"

        android:left="1dp"

        android:right="1dp"

        android:top="1dp">

        <shape>

            <gradient

                android:centerColor="#1FBDFF"

                android:endColor="#1FA5FF"

                android:startColor="#02EEFF"

                android:type="linear" />

            <!-- 圆角 -->

            <corners android:radius="4dp" />

        </shape>

    </item>

</layer-list>

3、TextView设置不同颜色

SpannableString receiver = new SpannableString(beanInfo.getUpdator() + "领取");

receiver.setSpan(new ForegroundColorSpan(Color.parseColor("#5B6175")), beanInfo.getUpdator().length(), beanInfo.getUpdator().length() + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

tvReceiver.setText(receiver);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!