当前位置: 首页 > news >正文

房价查询官网网站关键词seo优化怎么做

房价查询官网,网站关键词seo优化怎么做,WordPress禁用f12,苏州网页优化服务最近在做一个使用接口返回的字符串:"#ff0000" 来动态设置drawable背景颜色与动态设置状态选择器selector的需求,之前写习惯了shape的xml,还是第一次写动态的,有点搞笑,搞笑的是自己没写过,不知道…

最近在做一个使用接口返回的字符串:"#ff0000" 来动态设置drawable背景颜色与动态设置状态选择器selector的需求,之前写习惯了shape的xml,还是第一次写动态的,有点搞笑,搞笑的是自己没写过,不知道会不会写。

1.很简单,直接布局代码:

<RelativeLayoutandroid:id="@+id/ll_title"android:layout_width="match_parent"android:layout_marginRight="20dp"android:layout_marginLeft="20dp"android:layout_height="50dp"app:contentInsetStart="0dp"android:background="@drawable/shape_red_bg"tools:ignore="MissingConstraints"><TextViewandroid:id="@+id/toolbar_left"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="10dp"android:gravity="center"android:singleLine="true"android:text="菜单"android:textColor="@color/white"android:textSize="16dp"android:visibility="visible" /><TextViewandroid:id="@+id/toolbar_title"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:singleLine="true"android:text="居中标题"android:layout_centerInParent="true"android:textColor="@android:color/white"android:textSize="20dp"android:visibility="visible" /><TextViewandroid:id="@+id/toolbar_right"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="right"android:layout_marginRight="10dp"android:gravity="center"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:text="秘密"android:textColor="@color/white"android:textSize="16dp"android:visibility="visible" /></RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><!--    <size android:height="417dp" android:width="834dp"/>--><gradientandroid:gradientRadius="417dp"android:startColor="@color/red"android:endColor="@color/red"android:centerX="0.5"android:centerY="1"android:type="radial" /><cornersandroid:bottomLeftRadius="0dp"android:bottomRightRadius="0dp"android:topLeftRadius="0dp"android:topRightRadius="0dp" />
</shape>

2.Activity代码如下:

//在Activity的初始化中直接复制下面代码:
RelativeLayout llTitle = findViewById(R.id.ll_title);
llTitle.setBackgroundDrawable(getStateListDrawable());llTitle.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {}});//在Activity中的方法
public static StateListDrawable getStateListDrawable() {StateListDrawable selector = new StateListDrawable();int parseColor = Color.parseColor("#FF00FF");Drawable pressDrawable = getRoundRectDrawable(20, Color.parseColor("#ff00ff"), true, 0);Drawable selectDrawable = getRoundRectDrawable(20, Color.parseColor("#00ffff"), true, 0);Drawable defaultDrawable = getRoundRectDrawable(20, Color.parseColor("#00ffff"), true, 0);selector.addState(new int[]{android.R.attr.state_pressed}, pressDrawable);selector.addState(new int[]{android.R.attr.state_selected}, selectDrawable);// 添加一个默认状态, 默认状态必须写在其他状态的最后面, 否则其他状态失效selector.addState(new int[]{}, defaultDrawable);return selector;}public static GradientDrawable getRoundRectDrawable(int radius, int color, boolean isFill, int strokeWidth){//左上、右上、右下、左下的圆角半径float[] radiusList = {radius, radius, radius, radius, radius, radius, radius, radius};GradientDrawable drawable = new GradientDrawable();drawable.setCornerRadii(radiusList);drawable.setColor(isFill ? color : Color.TRANSPARENT);drawable.setStroke(isFill ? 0 : strokeWidth, color);return drawable;}
//补充设置渐变色
public static GradientDrawable getRoundRectDrawable(int radius, int color, boolean isFill, int strokeWidth){//左上、右上、右下、左下的圆角半径float[] radiusList = {radius, radius, radius, radius, radius, radius, radius, radius};GradientDrawable drawable = new GradientDrawable();//设置渐变色,渐变方向从左上到右下,渐变颜色设置GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TL_BR,new int[]{R.color.blue_0B1152, R.color.blue_4E5988});drawable.setCornerRadii(radiusList);drawable.setColor(isFill ? color : Color.TRANSPARENT);drawable.setStroke(isFill ? 0 : strokeWidth, color);return drawable;}

亲测有效,写这篇文章只是想记录一下完整的实现代码。

相关博客推荐:

Android状态选择器selector的详细使用汇总

selector的两种设置方式

http://www.yayakq.cn/news/222522/

相关文章:

  • 嵊州建设银行取款网站如何做网站优惠券推广
  • 无锡软件网站开发公司wordpress博客导出
  • 中国建设银行企业信息门户网站建设网站有什么法律么
  • 北京微网站建设建设公司网站需要注意哪些
  • 辽宁城乡建设部网站专门做家居的网站
  • 电商网站 appwordpress图像存储
  • 长春网站建设产品展示长沙自动化网站建设
  • 网站开发设计合同范本自己开个公司做网站
  • 深圳网站建设一般多少钱顺德大良那里做网站好
  • 苏州实力做网站公司有哪些网站开发制作的流程是什么
  • 1688货源网手机版seo职位信息
  • 二级域名做网站南昌百度推广联系方式
  • 门户网站建设与开发快速让百度收录网站
  • 铁道部售票网站多少钱建设国内十大4a广告公司
  • 公司网站建设优点wordpress建商城
  • 九江建网站多少钱wordpress 2m带宽 支持多少人
  • 安徽省建设厅网站电话微信社群运营主要是做什么的
  • 广州网站建设支付1920网页设计尺寸规范
  • 做网站心得国外做内容网站
  • 青岛正规网站设计公司尚普咨询市场调研公司
  • 效果好的网站建济南营销网站建设
  • 如何做汽车的创意视频网站会计网站模板
  • 南京网站设计ui百度app下载安装普通下载
  • 中国网站的特点适合网站开发的框架
  • 揭阳制作公司网站wordpress 父级页面
  • 做交互的设计网站成品播放器
  • 凡科网站模块兖州网站建设哪家便宜
  • 做一个网站成本要多少钱wordpress 全局广告
  • 全景网站如何做没公司怎么做网站
  • 可以做视频推广的网站吗烟台企业展厅设计