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

这个图有点意思,想想我们平时写这个流程,应该都会有一端会出头,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);
}
958

被折叠的 条评论
为什么被折叠?



