实现效果:可编辑表单,可按时间线增加多个子项,按钮可选择切换。
代码:
PageForm2Activity.java
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import com.ab.activity.AbActivity;
import com.ab.util.AbToastUtil;
import com.ab.view.slidingmenu.SlidingMenu;
import com.ab.view.titlebar.AbTitleBar;
import com.andbase.R;
import com.andbase.global.MyApplication;
import com.andbase.patrol.gtDemo.adapter.pagesAdapter.newPagesAdapter.PageForm2Adapter;
import com.andbase.patrol.gtDemo.model.LinkInfoFormDemo;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* author:lmx
* date:2018/3/19
* description:form2
*/
public class PageForm2Activity extends AbActivity{
private MyApplication application;
private SlidingMenu menu;
private AbTitleBar mAbTitleBar = null;
//加载不同布局
private PageForm2Activity context;
private ListView listview;
public List<LinkInfoFormDemo> listInfo = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setAbContentView(R.layout.newpages_activity_form2_demo);
application = (MyApplication)abApplication;
mAbTitleBar = this.getTitleBar();
mAbTitleBar.setTitleText("form2");
mAbTitleBar.setLogo(R.drawable.button_selector_back);
mAbTitleBar.setTitleBarBackground(R.drawable.top_bg);
mAbTitleBar.setTitleTextMargin(10, 0, 0, 0);
mAbTitleBar.setLogoLine(R.drawable.line);
this.setTitleBarOverlay(true);
//加载不同布局
this.listview = (ListView) findViewById(R.id.lvForm1);
context = this;
//顶部菜单 保存
initTitleRightLayout();
//加载数据
loadListView();
}
/**
* 加载listView数据
*/
public void loadListView(){
try {
listInfo = new ArrayList<LinkInfoFormDemo>();
//单选下拉测试数据
LinkedList<String> data_list = new LinkedList<String>();
data_list.add("否");
data_list.add("是");
LinkInfoFormDemo form1 = new LinkInfoFormDemo();
form1.setPropertyType(0);
form1.setTitle1("标题");
form1.setSingle("单行文本");
form1.setMore("多行文本");
form1.setTitle2("标题");
form1.setRange("取值范围");
form1.setLabel("标注");
listInfo.add(form1);
LinkInfoFormDemo form2 = new LinkInfoFormDemo();
form2.setPropertyType(0);
form2.setTitle1("标题");
form2.setSingle("单行文本");
form2.setMore("多行文本");
form2.setTitle2("标题");
form2.setRange("取值范围");
form2.setLabel("标注");
listInfo.add(form2);
}catch(Exception ex)
{
Log.e("JSON Error: ", ex.toString());
}
ListView listView = (ListView) findViewById(R.id.lvForm1);
PageForm2Adapter pageForm2Adapter = new PageForm2Adapter(context,listInfo);
listView.setAdapter(pageForm2Adapter);
}
/**
* 顶部菜单 保存
*/
private void initTitleRightLayout() {
mAbTitleBar.clearRightView();
View rightSave = mInflater.inflate(R.layout.save_btn_demo, null);
mAbTitleBar.addRightView(rightSave);
Button btnSave = (Button) rightSave.findViewById(R.id.saveBtn);
btnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AbToastUtil.showToast(context,"保存");
}
});
}
}
PageForm2Adapter.java
package com.andbase.patrol.gtDemo.adapter.pagesAdapter.newPagesAdapter;
import android.graphics.Color;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import com.ab.util.AbDialogUtil;
import com.andbase.R;
import com.andbase.patrol.gtDemo.activity.pages.newPages.PageForm2Activity;
import com.andbase.patrol.gtDemo.model.LinkInfoFormDemo;
import java.util.List;
/**
* author:lmx
* date:2018/3/19
* description:form2
*/
public class PageForm2Adapter extends BaseAdapter {
private PageForm2Activity mContext;
private List<LinkInfoFormDemo> lists;
private LayoutInflater layinf;
public PageForm2Adapter(PageForm2Activity context, List<LinkInfoFormDemo> lists){
this.mContext = context;
this.lists = lists;
layinf = LayoutInflater.from(context);
}
@Override
public int getCount() {
return lists.size();
}
@Override
public int getItemViewType(int position) {
//根据position返回指定的布局类型,比如0、1,根据这个返回值加载不同布局
return lists.get(position).getPropertyType();
}
@Override
public int getViewTypeCount() {
//这里是adapter里有几种布局
return 1;
}
@Override
public Object getItem(int position) {
return lists.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent){
LinkInfoFormDemo form = lists.get(position);
ViewHolder viewHolder = null;
if (form == null) {
return null;
}
if (convertView == null) {
switch (form.getPropertyType()){
case 0:
convertView = layinf.inflate(R.layout.newpages_form2_list_item_demo, parent, false);
//使用减少findView的次数
viewHolder = new PageForm2Adapter.ViewHolder();
viewHolder.ivLineTop = (ImageView) convertView.findViewById(R.id.ivLineTop);
viewHolder.ivLineBottom = (ImageView) convertView.findViewById(R.id.ivLineBottom);
viewHolder.tvTitle1 = (TextView) convertView.findViewById(R.id.tvTitle1);
viewHolder.tvSingle = (TextView) convertView.findViewById(R.id.tvSingle);
viewHolder.tvSelect = (TextView) convertView.findViewById(R.id.tvSelect);
viewHolder.tvMore = (TextView) convertView.findViewById(R.id.tvMore);
viewHolder.tvTitle2 = (TextView) convertView.findViewById(R.id.tvTitle2);
viewHolder.tvRange = (TextView) convertView.findViewById(R.id.tvRange);
viewHolder.tvLabel = (TextView) convertView.findViewById(R.id.tvLabel);
viewHolder.tvUnit = (TextView) convertView.findViewById(R.id.tvUnit);
viewHolder.etSingleValue = (EditText) convertView.findViewById(R.id.etSingleValue);
viewHolder.etMoreValue = (EditText) convertView.findViewById(R.id.etMoreValue);
viewHolder.etRangeValue = (EditText) convertView.findViewById(R.id.etRangeValue);
viewHolder.etRangeValue2 = (EditText) convertView.findViewById(R.id.etRangeValue2);
viewHolder.etLabelValue = (EditText) convertView.findViewById(R.id.etLabelValue);
viewHolder.btnA = (Button) convertView.findViewById(R.id.btnA);
viewHolder.btnB = (Button) convertView.findViewById(R.id.btnB);
viewHolder.btnC = (Button) convertView.findViewById(R.id.btnC);
//设置标记
convertView.setTag(viewHolder);
break;
}
} else {
switch (form.getPropertyType()){
case 0:
viewHolder = (PageForm2Adapter.ViewHolder) convertView.getTag();
break;
}
}
/**
* 根据不同布局加载不同数据
* */
switch (form.getPropertyType()){
case 0:
viewHolder.tvTitle1.setText(form.getTitle1());
viewHolder.tvSingle.setText(form.getSingle());
viewHolder.tvMore.setText(form.getMore());
viewHolder.tvTitle2.setText(form.getTitle2());
viewHolder.tvRange.setText(form.getRange());
viewHolder.tvLabel.setText(form.getLabel());
//按钮点击事件
final ViewHolder finalViewHolder = viewHolder;
final ViewHolder finalViewHolder1 = viewHolder;
final ViewHolder finalViewHolder2 = viewHolder;
viewHolder.btnA.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
finalViewHolder1.btnA.setBackgroundResource(R.drawable.btn_form2_bg_selected_demo);
finalViewHolder1.btnA.setTextColor(Color.WHITE);
finalViewHolder.btnB.setBackgroundResource(R.drawable.btn_form2_bg_unselected_demo);
finalViewHolder.btnB.setTextColor(Color.parseColor("#b2b2b2"));
finalViewHolder2.btnC.setBackgroundResource(R.drawable.btn_form2_bg_unselected_demo);
finalViewHolder.btnC.setTextColor(Color.parseColor("#b2b2b2"));
}
});
viewHolder.btnB.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
finalViewHolder.btnB.setBackgroundResource(R.drawable.btn_form2_bg_selected_demo);
finalViewHolder.btnB.setTextColor(Color.WHITE);
finalViewHolder1.btnA.setBackgroundResource(R.drawable.btn_form2_bg_unselected_demo);
finalViewHolder1.btnA.setTextColor(Color.parseColor("#b2b2b2"));
finalViewHolder2.btnC.setBackgroundResource(R.drawable.btn_form2_bg_unselected_demo);
finalViewHolder.btnC.setTextColor(Color.parseColor("#b2b2b2"));
}
});
viewHolder.btnC.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
finalViewHolder1.btnC.setBackgroundResource(R.drawable.btn_form2_bg_selected_demo);
finalViewHolder1.btnC.setTextColor(Color.WHITE);
finalViewHolder.btnB.setBackgroundResource(R.drawable.btn_form2_bg_unselected_demo);
finalViewHolder.btnB.setTextColor(Color.parseColor("#b2b2b2"));
finalViewHolder2.btnA.setBackgroundResource(R.drawable.btn_form2_bg_unselected_demo);
finalViewHolder.btnA.setTextColor(Color.parseColor("#b2b2b2"));
}
});
break;
}
//隐藏第一个item时间线的上方线和最后一个item的下方线
switch (position){
case 0:
viewHolder.ivLineTop.setBackgroundColor(Color.TRANSPARENT);
break;
case 1:
viewHolder.ivLineBottom.setBackgroundColor(Color.TRANSPARENT);
break;
default:
break;
}
return convertView;
}
/**
* ViewLinkDetailHolder类
*/
static class ViewHolder {
ImageView ivLineTop;//时间线
ImageView ivLineBottom;//时间线
TextView tvTitle1;//标题一
TextView tvSingle;//单行文本
EditText etSingleValue;//单行文本
TextView tvSelect;//选择类别
Button btnA;//选择类别
Button btnB;//选择类别
Button btnC;//选择类别
TextView tvMore;//多行文本
EditText etMoreValue;//多行文本
TextView tvTitle2;//标题2
TextView tvRange;//取值范围
EditText etRangeValue;//取值范围
EditText etRangeValue2;//取值范围
TextView tvLabel;//标注
EditText etLabelValue;//标注
TextView tvUnit;//单位
}
}
newpages_activity_form2_demo.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/gray_white">
<!-- 列表项 -->
<ListView
android:id="@+id/lvForm1"
android:divider="@null"
android:dividerHeight="@null"
android:scrollbars="none"
android:listSelector="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"
android:fadingEdge="none"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="55dip" />
</RelativeLayout>
LinkInfoFormDemo
newpages_form2_list_item_demo.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- 第一列 时间线 -->
<LinearLayout
android:layout_width="0dip"
android:layout_weight="0.1"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/ivLineTop"
android:layout_width="@dimen/history_ellist_line_width"
android:layout_height="@dimen/form2_line_h"
android:layout_marginLeft="@dimen/history_ellist_line_margin_left"
android:orientation="vertical"
android:background="@color/el_list_left_line_color" />
<ImageView
android:id="@+id/ivLineImg"
android:layout_width="@dimen/history_ellist_group_time"
android:layout_height="@dimen/history_ellist_group_time"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/history_ellist_group_time_margin"
android:src="@drawable/history_expand_top_point"
android:orientation="vertical"/>
<ImageView
android:id="@+id/ivLineBottom"
android:layout_width="@dimen/history_ellist_line_width"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/history_ellist_line_margin_left"
android:orientation="vertical"
android:background="@color/el_list_left_line_color" />
</LinearLayout>
<!-- 第二列 三角 -->
<LinearLayout
android:layout_width="0dip"
android:layout_weight="0.05"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/ivLineImg1"
android:layout_width="@dimen/history_ellist_group_time"
android:layout_height="@dimen/history_ellist_group_time"
android:layout_centerVertical="true"
android:layout_marginTop="@dimen/form2_line_h"
android:src="@drawable/line_img"
android:orientation="vertical"/>
</LinearLayout>
<!-- 第三列 信息名称 -->
<LinearLayout
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/form1_ll_right"
android:layout_marginTop="@dimen/form1_ll_top"
android:layout_marginBottom="@dimen/form2_ll_bottom"
android:orientation="vertical"
android:background="@drawable/form1_item_bg_demo">
<!-- 标题 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/form2_rl_top"
android:layout_marginLeft="@dimen/form2_title_left"
android:layout_marginRight="@dimen/form2_title_right">
<TextView
android:id="@+id/tvTitle1"
android:layout_width="@dimen/link_rl_tv_w"
android:layout_height="@dimen/link_rl_tv_h"
android:gravity="fill_vertical"
android:text="标题"
android:textColor="@color/title_text_color"
android:textSize="@dimen/table_body" />
</LinearLayout>
<View android:layout_width="match_parent"
android:layout_height="@dimen/link_line_h"
android:layerType="software"
android:background="@drawable/btn_form2_line_bg_demo"/>
<!-- 单行文本 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/form2_item_h"
android:orientation="horizontal"
android:layout_marginTop="@dimen/form2_title_top"
android:layout_marginLeft="@dimen/form2_title_left"
android:layout_marginRight="@dimen/form2_title_right">
<LinearLayout
android:layout_width="0dip"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h">
<TextView
android:id="@+id/tvSingle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill_vertical"
android:text="单行文本"
android:textColor="@color/title_text_color"
android:textSize="@dimen/table_body" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_weight="3"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h">
<EditText
android:id="@+id/etSingleValue"
android:background="@color/new_bg_color"
android:layout_width="match_parent"
android:layout_height="@dimen/form2_item_h"
android:paddingLeft="@dimen/form2_et_padding"
android:gravity="fill_vertical"
android:textSize="@dimen/table_body"
android:textColor="@color/project_word_color"
android:hint="@string/placeholder" />
</LinearLayout>
</LinearLayout>
<!-- 选择类别 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/form2_item_h"
android:orientation="horizontal"
android:layout_marginTop="@dimen/form2_title_top"
android:layout_marginLeft="@dimen/form2_title_left"
android:layout_marginRight="@dimen/form2_title_right">
<LinearLayout
android:layout_width="0dip"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h">
<TextView
android:id="@+id/tvSelect"
android:layout_width="@dimen/link_rl_tv_w"
android:layout_height="match_parent"
android:gravity="fill_vertical"
android:text="选择类别"
android:textColor="@color/title_text_color"
android:textSize="@dimen/table_body" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_weight="3"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="@dimen/form2_ll_height"
android:layout_marginTop="@dimen/form2_ll_top"
android:orientation="horizontal">
<Button
android:id="@+id/btnA"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/btn_form2_bg_selected_demo"
android:text="A类"
android:gravity="center"
android:textColor="@color/white"
android:textSize="@dimen/table_body" />
<TextView
android:layout_width="0dip"
android:layout_weight="0.15"
android:layout_height="match_parent"/>
<Button
android:id="@+id/btnB"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/btn_form2_bg_unselected_demo"
android:text="B类"
android:gravity="center"
android:textColor="@color/details_fix_text_color"
android:textSize="@dimen/table_body" />
<TextView
android:layout_width="0dip"
android:layout_weight="0.15"
android:layout_height="match_parent"/>
<Button
android:id="@+id/btnC"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@drawable/btn_form2_bg_unselected_demo"
android:text="C类"
android:gravity="center"
android:textColor="@color/details_fix_text_color"
android:textSize="@dimen/table_body" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- 多行文本 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/form2_item_h2"
android:orientation="horizontal"
android:layout_marginTop="@dimen/form2_title_top"
android:layout_marginLeft="@dimen/form2_title_left"
android:layout_marginRight="@dimen/form2_title_right">
<LinearLayout
android:layout_width="0dip"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h">
<TextView
android:id="@+id/tvMore"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill_vertical"
android:text="多行文本"
android:textColor="@color/title_text_color"
android:textSize="@dimen/table_body" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_weight="3"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h2">
<EditText
android:id="@+id/etMoreValue"
android:background="@color/new_bg_color"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:paddingTop="@dimen/form2_et_padding"
android:paddingLeft="@dimen/form2_et_padding"
android:textSize="@dimen/table_body"
android:textColor="@color/project_word_color"
android:hint="@string/placeholder" />
</LinearLayout>
</LinearLayout>
<View android:layout_width="match_parent"
android:layout_height="@dimen/link_line_h"
android:layout_marginTop="@dimen/form2_title_top"
android:layerType="software"
android:background="@drawable/btn_form2_line_bg_demo"/>
<!-- 标题 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/form2_rl_top"
android:layout_marginLeft="@dimen/form2_title_left"
android:layout_marginRight="@dimen/form2_title_right">
<TextView
android:id="@+id/tvTitle2"
android:layout_width="@dimen/link_rl_tv_w"
android:layout_height="@dimen/link_rl_tv_h"
android:gravity="fill_vertical"
android:text="标题"
android:textColor="@color/title_text_color"
android:textSize="@dimen/table_body" />
</LinearLayout>
<View android:layout_width="match_parent"
android:layout_height="@dimen/link_line_h"
android:layerType="software"
android:background="@drawable/btn_form2_line_bg_demo"/>
<!-- 取值范围 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/form2_item_h"
android:orientation="horizontal"
android:layout_marginTop="@dimen/form2_title_top"
android:layout_marginLeft="@dimen/form2_title_left"
android:layout_marginRight="@dimen/form2_title_right">
<LinearLayout
android:layout_width="0dip"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h">
<TextView
android:id="@+id/tvRange"
android:layout_width="@dimen/link_rl_tv_w"
android:layout_height="match_parent"
android:gravity="fill_vertical"
android:text="取值范围"
android:textColor="@color/title_text_color"
android:textSize="@dimen/table_body" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_weight="3"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="@dimen/form2_ll_height"
android:layout_marginTop="@dimen/form2_ll_top"
android:orientation="horizontal">
<EditText
android:id="@+id/etRangeValue"
android:background="@color/new_bg_color"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:paddingLeft="@dimen/form2_et_padding"
android:gravity="fill_vertical"
android:textSize="@dimen/table_body"
android:textColor="@color/project_word_color"
android:hint="@string/placeholder" />
<TextView
android:layout_width="0dip"
android:layout_weight="0.4"
android:layout_height="match_parent"
android:gravity="center"
android:text="~"
android:textColor="@color/title_text_color"/>
<EditText
android:id="@+id/etRangeValue2"
android:background="@color/new_bg_color"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:paddingLeft="@dimen/form2_et_padding"
android:gravity="fill_vertical"
android:textSize="@dimen/table_body"
android:textColor="@color/project_word_color"
android:hint="@string/placeholder" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!-- 标注 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/form2_item_h"
android:orientation="horizontal"
android:layout_marginTop="@dimen/form2_title_top"
android:layout_marginLeft="@dimen/form2_title_left"
android:layout_marginRight="@dimen/form2_title_right">
<LinearLayout
android:layout_width="0dip"
android:layout_weight="1"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h">
<TextView
android:id="@+id/tvLabel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="fill_vertical"
android:text="标注"
android:textColor="@color/title_text_color"
android:textSize="@dimen/table_body" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_weight="3"
android:orientation="vertical"
android:layout_height="@dimen/form2_item_h">
<EditText
android:id="@+id/etLabelValue"
android:background="@color/new_bg_color"
android:layout_width="match_parent"
android:layout_height="@dimen/form2_item_h"
android:paddingLeft="@dimen/form2_et_padding"
android:gravity="fill_vertical"
android:textSize="@dimen/table_body"
android:textColor="@color/project_word_color"
android:hint="@string/placeholder" />
</LinearLayout>
</LinearLayout>
<!-- 单位 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/form2_item_h"
android:orientation="horizontal"
android:layout_marginTop="@dimen/form2_title_top"
android:layout_marginLeft="@dimen/form2_title_left"
android:layout_marginRight="@dimen/form2_title_right">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right">
<TextView
android:id="@+id/tvUnit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="right"
android:text="*单位为千米"
android:textColor="@color/pages_btn_do_color"
android:textSize="@dimen/tb_body" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
btn_form2_bg_selected_demo.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- 按钮正常的时候的背景 -->
<!-- shape的默认形状是rectangle,还有oval(椭圆),line(线),ring(圆环)-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 矩形的圆角弧度 -->
<corners android:radius="15dp" />
<!-- 矩形的填充色 -->
<solid android:color="#33ccc7" />
<!-- 边界线为实线 -->
<stroke
android:width="1dp"
android:color="#33ccc7" />
</shape>
btn_form2_bg_unselected_demo.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- 按钮正常的时候的背景 -->
<!-- shape的默认形状是rectangle,还有oval(椭圆),line(线),ring(圆环)-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 矩形的圆角弧度 -->
<corners android:radius="15dp" />
<!-- 矩形的填充色 -->
<solid android:color="#FFF" />
<!-- 边界线为实线 -->
<stroke
android:width="1dp"
android:color="#c7c7c7" />
</shape>
虚线是设置:View里需要加上android:layerType="software"
<View android:layout_width="match_parent"
android:layout_height="@dimen/link_line_h"
android:layerType="software"
android:background="@drawable/btn_form2_line_bg_demo"/>
btn_form2_line_bg_demo.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:dashGap="2dp"
android:dashWidth="2dp"
android:width="0.5dp"
android:color="#e1e1e1" />
</shape>
dimens.xml
<!-- form1 -->
<dimen name="form1_ll_left">10dip</dimen>
<dimen name="form1_ll_right">10dip</dimen>
<dimen name="form1_ll_bottom">20dip</dimen>
<dimen name="form1_ll_top">15dip</dimen>
<dimen name="form1_rl_top">20dip</dimen>
<dimen name="form1_sp_top">2dip</dimen>
<dimen name="form1_sp_right">20dip</dimen>
<dimen name="form1_img_w">12dip</dimen>
<dimen name="form1_img_h">16dip</dimen>
<dimen name="form1_img_top">12dip</dimen>
<dimen name="form1_img_right">15dip</dimen>
<dimen name="form1_fg_top">-356dip</dimen>
<dimen name="form1_btn_w">150dip</dimen>
<dimen name="form1_btn_padding">5dip</dimen>
<!-- form2 -->
<dimen name="form2_rl_top">5dip</dimen>
<dimen name="form2_line_h">30dip</dimen>
<dimen name="form2_ll_bottom">10dip</dimen>
<dimen name="form2_ll_height">25dip</dimen>
<dimen name="form2_ll_top">2.5dip</dimen>
<dimen name="form2_title_left">10dip</dimen>
<dimen name="form2_title_right">10dip</dimen>
<dimen name="form2_title_top">10dip</dimen>
<dimen name="form2_item_h">30dip</dimen>
<dimen name="form2_item_h2">60dip</dimen>
<dimen name="form2_et_padding">5dip</dimen>
完。