Android:流程图

其中有一个流程图,这个流程图中间有一条竖线

看一下图

在这里插入图片描述

这个图有点意思,想想我们平时写这个流程,应该都会有一端会出头,item是这个样子的
在这里插入图片描述
一个竖线直插云霄
一般直接new这个布局,会出现第一个这个冒出来,并不好看
那么,怎么消呢

我这边试了两种:

一种是将上面的布局抬高1dp android:elevation=“1dp”

这个流程(id == ll_response_list)布局 android:layout_marginTop="-20dp"
这个方法,很贱
直接就把下面的这个尖尖遮住了,但是由于抬高了1dp,会有阴影,导致并不好看


所以我推荐第二个, 我这边直接上源码,下面有说明

item_plan_response.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/ll_response"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:gravity="center"
    android:orientation="vertical">
    <View
        android:id="@+id/v_line"
        android:layout_width="1dp"
        android:layout_height="20dp"
        android:background="#1E90FF" />
    <TextView
        android:id="@+id/tv_response_title"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="@drawable/item_border_dashed"
        android:gravity="center"
        android:text="@string/app_name"
        android:textColor="#1E90FF" />
</LinearLayout>

这个是存放流程的布局,ll_response_list

<LinearLayout
    android:layout_marginLeft="100dp"
    android:layout_marginRight="100dp"
    android:orientation="vertical"
    android:id="@+id/ll_response_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

</LinearLayout>

核心方法的代码块

    private ArrayList<PlanResponses> planResponsesArrayList = new ArrayList<PlanResponses>();
    private PlanResponses planResponses;
    private void PlanResponses_V(String arraydata){

        List<PlanResponses> sio = JSON.parseArray(arraydata, PlanResponses.class);
        for (PlanResponses pp : sio) {
            planResponses = new PlanResponses();
            planResponses.setTitle(pp.getTitle());
            planResponsesArrayList.add(planResponses);
            //设置大小
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            //lp.setMargins(0,30,0,0);//4个参数按顺序分别是左上右下
            LinearLayout head_portrait = (LinearLayout) LayoutInflater.from(PlanTypeDetailActivity.this).inflate(R.layout.item_plan_response, null);
            head_portrait.setLayoutParams(lp);
            LinearLayout ll_response = (LinearLayout) head_portrait.findViewById(R.id.ll_response);
            TextView tv_response_title = (TextView) ll_response.findViewById(R.id.tv_response_title);
            tv_response_title.setText(pp.getTitle());
            if(planResponsesArrayList.get(0).getTitle().equals(pp.getTitle())){
                View v_line =  (View) ll_response.findViewById(R.id.v_line);
                v_line.setVisibility(View.GONE);
                ll_response_list.addView(ll_response);
            }else {
                ll_response_list.addView(ll_response);
            }
        }
    }

着重看一下这个

我做了一下判断,判断哪一个是ArrayList当中的第一个,(当然啦,默认是0开始,这个不谈)如果是,就把item布局当中的竖线隐藏掉,这样,就不会显示了

 if(planResponsesArrayList.get(0).getTitle().equals(pp.getTitle())){
                View v_line =  (View) ll_response.findViewById(R.id.v_line);
                v_line.setVisibility(View.GONE);
                ll_response_list.addView(ll_response);
            }else {
                ll_response_list.addView(ll_response);
            }

end~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Wenlong Yang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值