Android 時(shí)間線表單

實(shí)現(xiàn)效果:可編輯表單助析,可按時(shí)間線增加多個(gè)子項(xiàng)切省,按鈕可選擇切換斗塘。


image.png

代碼:
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();

        //加載數(shù)據(jù)
        loadListView();
    }
    /**
     * 加載listView數(shù)據(jù)
     */
    public void loadListView(){
        try {
            listInfo = new ArrayList<LinkInfoFormDemo>();
            //單選下拉測(cè)試數(shù)據(jù)
            LinkedList<String> data_list = new LinkedList<String>();
            data_list.add("否");
            data_list.add("是");

            LinkInfoFormDemo form1 = new LinkInfoFormDemo();
            form1.setPropertyType(0);
            form1.setTitle1("標(biāo)題");
            form1.setSingle("單行文本");
            form1.setMore("多行文本");
            form1.setTitle2("標(biāo)題");
            form1.setRange("取值范圍");
            form1.setLabel("標(biāo)注");
            listInfo.add(form1);

            LinkInfoFormDemo form2 = new LinkInfoFormDemo();
            form2.setPropertyType(0);
            form2.setTitle1("標(biāo)題");
            form2.setSingle("單行文本");
            form2.setMore("多行文本");
            form2.setTitle2("標(biāo)題");
            form2.setRange("取值范圍");
            form2.setLabel("標(biāo)注");
            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) {
        //根據(jù)position返回指定的布局類型膀藐,比如0媚值、1睦焕,根據(jù)這個(gè)返回值加載不同布局
        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的次數(shù)
                    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);
                    //設(shè)置標(biāo)記
                    convertView.setTag(viewHolder);
                    break;
            }
        } else {
            switch (form.getPropertyType()){
                case 0:
                    viewHolder = (PageForm2Adapter.ViewHolder) convertView.getTag();
                    break;
            }
        }
        /**
         * 根據(jù)不同布局加載不同數(shù)據(jù)
         * */
        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());
                //按鈕點(diǎn)擊事件
                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;
        }
        //隱藏第一個(gè)item時(shí)間線的上方線和最后一個(gè)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;//時(shí)間線
        ImageView ivLineBottom;//時(shí)間線
        TextView tvTitle1;//標(biāo)題一
        TextView tvSingle;//單行文本
        EditText etSingleValue;//單行文本
        TextView tvSelect;//選擇類別
        Button btnA;//選擇類別
        Button btnB;//選擇類別
        Button btnC;//選擇類別
        TextView tvMore;//多行文本
        EditText etMoreValue;//多行文本
        TextView tvTitle2;//標(biāo)題2
        TextView tvRange;//取值范圍
        EditText etRangeValue;//取值范圍
        EditText etRangeValue2;//取值范圍
        TextView tvLabel;//標(biāo)注
        EditText etLabelValue;//標(biāo)注
        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">

    <!-- 列表項(xiàng) -->
    <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


image.png

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">

    <!-- 第一列 時(shí)間線 -->
    <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">

        <!-- 標(biāo)題 -->
        <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="標(biāo)題"
                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"/>

        <!-- 標(biāo)題 -->
        <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="標(biāo)題"
                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>

        <!-- 標(biāo)注 -->
        <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="標(biāo)注"
                    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"?>
<!-- 按鈕正常的時(shí)候的背景 -->
<!-- shape的默認(rèn)形狀是rectangle藐握,還有oval(橢圓),line(線),ring(圓環(huán))-->

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 矩形的圓角弧度 -->
    <corners android:radius="15dp" />
    <!-- 矩形的填充色 -->
    <solid android:color="#33ccc7" />

    <!-- 邊界線為實(shí)線 -->
    <stroke
        android:width="1dp"
        android:color="#33ccc7" />
</shape>

btn_form2_bg_unselected_demo.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- 按鈕正常的時(shí)候的背景 -->
<!-- shape的默認(rèn)形狀是rectangle,還有oval(橢圓),line(線),ring(圓環(huán))-->

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 矩形的圓角弧度 -->
    <corners android:radius="15dp" />
    <!-- 矩形的填充色 -->
    <solid android:color="#FFF" />

    <!-- 邊界線為實(shí)線 -->
    <stroke
        android:width="1dp"
        android:color="#c7c7c7" />
</shape>

虛線是設(shè)置: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>

完垃喊。


image.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末猾普,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子缔御,更是在濱河造成了極大的恐慌抬闷,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,423評(píng)論 6 491
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異笤成,居然都是意外死亡评架,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,147評(píng)論 2 385
  • 文/潘曉璐 我一進(jìn)店門炕泳,熙熙樓的掌柜王于貴愁眉苦臉地迎上來纵诞,“玉大人,你說我怎么就攤上這事培遵≌丬剑” “怎么了?”我有些...
    開封第一講書人閱讀 157,019評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵籽腕,是天一觀的道長(zhǎng)嗡呼。 經(jīng)常有香客問我,道長(zhǎng)皇耗,這世上最難降的妖魔是什么南窗? 我笑而不...
    開封第一講書人閱讀 56,443評(píng)論 1 283
  • 正文 為了忘掉前任,我火速辦了婚禮郎楼,結(jié)果婚禮上万伤,老公的妹妹穿的比我還像新娘。我一直安慰自己呜袁,他們只是感情好敌买,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,535評(píng)論 6 385
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著阶界,像睡著了一般虹钮。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上荐操,一...
    開封第一講書人閱讀 49,798評(píng)論 1 290
  • 那天芜抒,我揣著相機(jī)與錄音,去河邊找鬼托启。 笑死宅倒,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的屯耸。 我是一名探鬼主播拐迁,決...
    沈念sama閱讀 38,941評(píng)論 3 407
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼疗绣!你這毒婦竟也來了线召?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,704評(píng)論 0 266
  • 序言:老撾萬榮一對(duì)情侶失蹤多矮,失蹤者是張志新(化名)和其女友劉穎缓淹,沒想到半個(gè)月后哈打,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,152評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡讯壶,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,494評(píng)論 2 327
  • 正文 我和宋清朗相戀三年料仗,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片伏蚊。...
    茶點(diǎn)故事閱讀 38,629評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡立轧,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出躏吊,到底是詐尸還是另有隱情氛改,我是刑警寧澤,帶...
    沈念sama閱讀 34,295評(píng)論 4 329
  • 正文 年R本政府宣布比伏,位于F島的核電站胜卤,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏赁项。R本人自食惡果不足惜瑰艘,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,901評(píng)論 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望肤舞。 院中可真熱鬧,春花似錦均蜜、人聲如沸李剖。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,742評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽篙顺。三九已至,卻和暖如春充择,著一層夾襖步出監(jiān)牢的瞬間德玫,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,978評(píng)論 1 266
  • 我被黑心中介騙來泰國(guó)打工椎麦, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留宰僧,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,333評(píng)論 2 360
  • 正文 我出身青樓观挎,卻偏偏與公主長(zhǎng)得像琴儿,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子嘁捷,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,499評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容

  • 記得剛開始學(xué)Android時(shí)造成,看著自己完全用系統(tǒng)控件寫出的不忍直視的界面,對(duì)于如何做出不一樣的按鈕雄嚣,讓它們?cè)诓煌瑺?..
    biloba閱讀 1,701評(píng)論 1 11
  • 財(cái)報(bào)是反應(yīng)一家公司收支盈虧和現(xiàn)金流數(shù)據(jù)最為詳細(xì)和客觀的一手資料晒屎,對(duì)于股票投資來說,必須掌握閱讀財(cái)報(bào)的方法,才能從一...
    馬天亮閱讀 342評(píng)論 0 0
  • 首先鼓鲁,我已經(jīng)訂閱了李笑來的《通往財(cái)富自由之路》的專欄蕴轨,每日學(xué)習(xí),雖然最近學(xué)習(xí)的沒有這么深入了坐桩,但是每天的文章肯定是...
    知樂行閱讀 1,107評(píng)論 0 0
  • 立秋 荷葉碧寬珠露淺 云煙雨思秋意濃 山疊風(fēng)險(xiǎn)峽徑上 夕下暮色一天長(zhǎng) 曉云 秦月漢山酒煮劍 曉日殘...
    可頓閱讀 189評(píng)論 0 1
  • “WOOP”方法尺棋,是幾個(gè)英文單詞的縮寫。從夢(mèng)想到現(xiàn)實(shí)绵跷,一共分四步 —— Wish膘螟。你想要干什么。比如說你想要一個(gè)好...
    Zc_Hwong閱讀 845評(píng)論 0 0