From b82bada93690fa03574561f298fd116796353343 Mon Sep 17 00:00:00 2001 From: endian11 <Dana_Lee1016@126.com> Date: 星期二, 19 三月 2019 10:15:36 +0800 Subject: [PATCH] 完善考试界面1 --- app/src/main/res/layout/layout_train_exit.xml | 6 app/src/main/res/layout/layout_net_train_item.xml | 44 ++++ app/src/main/res/layout/layout_train_fragment.xml | 6 app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java | 7 app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java | 74 +++++++ app/src/main/res/layout/layout_net_train.xml | 49 ++++ app/src/main/res/layout/profile_layout.xml | 233 ++++++++++++---------- app/src/main/java/safeluck/drive/evaluation/util/Utils.java | 16 + app/src/main/java/safeluck/drive/evaluation/customview/HouseView.java | 74 +++++++ app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java | 30 +++ app/src/main/res/values/colors.xml | 2 11 files changed, 431 insertions(+), 110 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java b/app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java new file mode 100644 index 0000000..e9b155b --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/customview/ArrowView.java @@ -0,0 +1,74 @@ +package safeluck.drive.evaluation.customview; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.support.annotation.Nullable; +import android.text.Layout; +import android.text.StaticLayout; +import android.text.TextPaint; +import android.util.AttributeSet; +import android.view.View; + +import safeluck.drive.evaluation.util.Utils; + +/** + * MyApplication2 + * Created by lzw on 2019/3/18. 11:18:47 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class ArrowView extends View { + + private Path path = new Path(); + private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + private float PADDING = Utils.px2dp(40); + private double a = Math.toRadians(55.0); + private int color = Color.parseColor("#99C3D1"); + private String text = "鐩磋杞集"; + private Path textPath = new Path(); + + public ArrowView(Context context) { + super(context); + } + + public ArrowView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public ArrowView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + path.moveTo(getWidth()/2-PADDING,getHeight()/2-PADDING); + path.rLineTo(PADDING,0); + path.rLineTo(PADDING*(float)Math.cos(a),PADDING*(float)Math.sin(a)); + path.rLineTo(-PADDING*(float)Math.cos(a),PADDING*(float)Math.sin(a)); + path.rLineTo(-(PADDING),0); + path.rLineTo(PADDING*(float)Math.cos(a),-PADDING*(float)Math.sin(a)); + path.rLineTo(-PADDING*(float)Math.cos(a),-PADDING*(float)Math.sin(a)); + path.close(); + paint.setColor(color); + canvas.drawPath(path,paint); + paint.setColor(Color.parseColor("#1412f6")); + char[] index = getKeyChar(text); + Paint.FontMetrics fm = paint.getFontMetrics(); + float childHeight = PADDING/text.length(); + for (int i = 0; i < text.length(); i++) { + canvas.drawText(String.valueOf(index[i]),getWidth()/2-PADDING/3, (float) (((i + 0.5) * childHeight) - (fm.ascent + fm.descent) / 2)+PADDING/3, paint); + } + } + + protected char[] getKeyChar(String str) { + char[] keys = new char[str.length()]; + for (int i = 0; i < keys.length; i++) { + keys[i] = str.charAt(i); + } + return keys; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/customview/HouseView.java b/app/src/main/java/safeluck/drive/evaluation/customview/HouseView.java new file mode 100644 index 0000000..a324800 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/customview/HouseView.java @@ -0,0 +1,74 @@ +package safeluck.drive.evaluation.customview; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.Rect; +import android.graphics.RectF; +import android.support.annotation.Nullable; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.View; + +import safeluck.drive.evaluation.util.Utils; + +/** + * MyApplication2 + * Created by lzw on 2019/3/18. 11:18:57 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class HouseView extends View { + + private Path path = new Path(); + private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + private float PADDING = Utils.px2dp(40); + private double a = Math.toRadians(55.0); + private int color = Color.parseColor("#99C3D1"); + private String text = "鍊掕溅鍏ュ簱"; + + + + public HouseView(Context context) { + super(context); + } + + public HouseView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public HouseView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + path.moveTo(getWidth()/2-PADDING,getHeight()/2-PADDING); + path.rLineTo(PADDING,0); + path.rLineTo(PADDING*(float)Math.cos(a),PADDING*(float)Math.sin(a)); + path.rLineTo(-PADDING*(float)Math.cos(a),PADDING*(float)Math.sin(a)); + path.rLineTo(-(PADDING),0); + path.rLineTo(0,PADDING); + path.close(); + paint.setColor(color); + canvas.drawPath(path,paint); + paint.setColor(Color.parseColor("#1412f6")); + char[] index = getKeyChar(text); + Paint.FontMetrics fm = paint.getFontMetrics(); + float childHeight = PADDING/text.length(); + for (int i = 0; i < text.length(); i++) { + canvas.drawText(String.valueOf(index[i]),getWidth()/2-PADDING/3, (float) (((i + 0.5) * childHeight) - (fm.ascent + fm.descent) / 2)+PADDING/3, paint); + } + } + + protected char[] getKeyChar(String str) { + char[] keys = new char[str.length()]; + for (int i = 0; i < keys.length; i++) { + keys[i] = str.charAt(i); + } + return keys; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java index a98c2e5..fde4d19 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/HomeFragment.java @@ -57,6 +57,13 @@ } break; case R.id.network_train: + NetWorkTrainFragment netWorkTrainFragment = findFragment(NetWorkTrainFragment.class); + if (netWorkTrainFragment == null){ + netWorkTrainFragment = (NetWorkTrainFragment)NetWorkTrainFragment.newInstance(); + start(netWorkTrainFragment); + }else{ + start(netWorkTrainFragment); + } //鑱旂綉鑰冭瘯 break; case R.id.exit_sys: diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java new file mode 100644 index 0000000..513b24d --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/NetWorkTrainFragment.java @@ -0,0 +1,30 @@ +package safeluck.drive.evaluation.fragment; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import me.yokeyword.fragmentation.SupportFragment; +import safeluck.drive.evaluation.R; + +/** + * MyApplication2 + * Created by lzw on 2019/3/18. 13:33:14 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class NetWorkTrainFragment extends SupportFragment { + public static SupportFragment newInstance() { + return new NetWorkTrainFragment(); + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.layout_net_train,container,false); + return view; + } +} diff --git a/app/src/main/java/safeluck/drive/evaluation/util/Utils.java b/app/src/main/java/safeluck/drive/evaluation/util/Utils.java new file mode 100644 index 0000000..46546d9 --- /dev/null +++ b/app/src/main/java/safeluck/drive/evaluation/util/Utils.java @@ -0,0 +1,16 @@ +package safeluck.drive.evaluation.util; + +import android.content.res.Resources; +import android.util.TypedValue; + +/** + * MyApplication2 + * Created by lzw on 2019/3/18. 13:13:42 + * 閭锛�632393724@qq.com + * All Rights Saved! Chongqing AnYun Tech co. LTD + */ +public class Utils { + public static float px2dp(float value){ + return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,value, Resources.getSystem().getDisplayMetrics()); + } +} diff --git a/app/src/main/res/layout/layout_net_train.xml b/app/src/main/res/layout/layout_net_train.xml new file mode 100644 index 0000000..9b6ebb9 --- /dev/null +++ b/app/src/main/res/layout/layout_net_train.xml @@ -0,0 +1,49 @@ +<?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="match_parent" + android:padding="5dp" + android:gravity="center" + android:orientation="vertical" + android:background="@color/train_bg" +> + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/tv_item" + android:background="@color/train_item_bg" + android:padding="10dp" + android:text="椤圭洰鍒楄〃"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:layout_toRightOf="@+id/tv_item" + android:gravity="center" + android:padding="10dp" + android:id="@+id/tv_speed" + android:text="杞﹂�燂細"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_toRightOf="@+id/tv_speed" + android:id="@+id/tv_pos" + android:padding="10dp" + android:gravity="center" + android:text="宸茶椹讹細45km"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鍛煎彨璇锋眰" + android:textColor="@android:color/white" + android:padding="10dp" + android:layout_marginBottom="2dp" + android:background="@color/colorAccent" + android:layout_toRightOf="@+id/tv_pos"/> + </RelativeLayout> +<include layout="@layout/layout_net_train_item"/> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_net_train_item.xml b/app/src/main/res/layout/layout_net_train_item.xml new file mode 100644 index 0000000..a0aad0f --- /dev/null +++ b/app/src/main/res/layout/layout_net_train_item.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="5dp" + android:background="@color/train_item_bg" + android:gravity="bottom"> + +<safeluck.drive.evaluation.customview.HouseView + android:layout_width="80dp" + android:layout_height="80dp" + android:id="@+id/hv" + /> + + <safeluck.drive.evaluation.customview.ArrowView + android:layout_width="80dp" + android:layout_height="80dp" + android:layout_toRightOf="@+id/hv" + android:id="@+id/av1" + android:layout_marginLeft="-15dp" + /> + <safeluck.drive.evaluation.customview.ArrowView + android:layout_width="80dp" + android:layout_height="80dp" + android:layout_marginLeft="-15dp" + android:layout_toRightOf="@+id/av1" + android:id="@+id/av2" + /> + <safeluck.drive.evaluation.customview.ArrowView + android:layout_width="80dp" + android:layout_height="80dp" + android:id="@+id/av3" + android:layout_marginLeft="-15dp" + android:layout_toRightOf="@id/av2" + /> + <safeluck.drive.evaluation.customview.ArrowView + android:layout_width="80dp" + android:layout_height="80dp" + android:layout_marginLeft="-15dp" + android:layout_toRightOf="@+id/av3" + android:id="@+id/av4" + + /> +</RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_train_exit.xml b/app/src/main/res/layout/layout_train_exit.xml new file mode 100644 index 0000000..f9504c9 --- /dev/null +++ b/app/src/main/res/layout/layout_train_exit.xml @@ -0,0 +1,6 @@ +<?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="match_parent"> + +</LinearLayout> diff --git a/app/src/main/res/layout/layout_train_fragment.xml b/app/src/main/res/layout/layout_train_fragment.xml index a758f1f..5d0638b 100644 --- a/app/src/main/res/layout/layout_train_fragment.xml +++ b/app/src/main/res/layout/layout_train_fragment.xml @@ -4,7 +4,7 @@ android:layout_height="match_parent" android:orientation="vertical" android:background="@color/home_bg_color"> -<include android:layout_weight="1" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/profile" layout="@layout/profile_layout"/> -<include android:layout_marginTop="10dp" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/profile" layout="@layout/profile_layout"/> -<include android:layout_weight="1" android:layout_marginTop="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/profile" layout="@layout/profile_layout"/> +<include android:layout_marginBottom="10dp" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp" android:id="@+id/profile" layout="@layout/profile_layout"/> +<include android:layout_marginBottom="10dp" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp" android:id="@+id/profile" layout="@layout/profile_layout"/> +<include android:layout_marginBottom="10dp" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="0dp" android:id="@+id/profile" layout="@layout/layout_net_train"/> </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/profile_layout.xml b/app/src/main/res/layout/profile_layout.xml index 752cbe5..ce9adec 100644 --- a/app/src/main/res/layout/profile_layout.xml +++ b/app/src/main/res/layout/profile_layout.xml @@ -1,137 +1,156 @@ <?xml version="1.0" encoding="utf-8"?> -<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="120dp" - xmlns:app="http://schemas.android.com/apk/res-auto" - app:cardElevation="10dp" - app:cardBackgroundColor="@color/colorAccent" - > + android:layout_height="match_parent" + android:background="@color/colorAccent" + android:gravity="center" + android:orientation="horizontal" + android:padding="10dp"> + + <ImageView + android:id="@+id/iv_head" + android:layout_width="0dp" + android:layout_height="70dp" + android:layout_weight="0.5" + android:scaleType="fitXY" + + android:src="@drawable/header" /> <LinearLayout - android:layout_width="match_parent" + android:layout_width="0dp" android:layout_height="wrap_content" - android:orientation="horizontal" - android:padding="10dp"> + android:layout_marginLeft="10dp" + android:layout_weight="3.5" + android:orientation="vertical"> - - - <ImageView - android:layout_weight="1" - android:layout_width="40dp" - android:layout_height="70dp" - android:id="@+id/iv_head"/> - <RelativeLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content"> - - </RelativeLayout> <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="4" - android:orientation="horizontal"> + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:orientation="horizontal" + > + <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" android:id="@+id/tv_name" - android:text="濮撳悕:lizanwei" - android:textColor="@color/colorPrimary" - android:layout_toRightOf="@+id/iv_head"/> - <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="鎬у埆:鐢�" + android:layout_toRightOf="@+id/iv_head" android:layout_weight="1" + android:text="濮撳悕:lizanwei" + android:textColor="@color/colorPrimary" /> + + <TextView android:id="@+id/tv_sex" - android:layout_toRightOf="@+id/tv_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" - android:textColor="@color/colorPrimary"/> + android:layout_toRightOf="@+id/tv_name" + android:layout_weight="1" + android:text="鎬у埆:鐢�" + android:textColor="@color/colorPrimary" /> + <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="鐢靛瓙鏁欑粌:楂樼骇" - android:layout_weight="1" android:layout_toRightOf="@+id/tv_sex" - android:textColor="@color/colorPrimary"/> + android:layout_weight="1" + android:text="鐢靛瓙鏁欑粌:楂樼骇" + android:textColor="@color/colorPrimary" /> </LinearLayout> + <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - ></LinearLayout> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/user_id" - android:layout_below="@+id/tv_name" - android:id="@+id/tv_ID" - android:textColor="@color/colorPrimary" - android:layout_toRightOf="@+id/iv_head"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:id="@+id/tv_start_time" - android:text="寮�濮嬫椂闂达細" - android:layout_below="@+id/tv_ID" - android:textColor="@color/colorPrimary" - android:layout_toRightOf="@+id/iv_head"/> + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_marginTop="5dp" + android:layout_marginBottom="5dp" + android:layout_weight="1" + > - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/inspector" - android:layout_toRightOf="@+id/tv_ID" - android:layout_below="@+id/tv_name" - android:id="@+id/inspect" - android:textColor="@color/colorPrimary"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="鐢ㄦ椂:" - android:layout_marginRight="10dp" - android:layout_marginLeft="10dp" - android:id="@+id/tv_use_time" - android:layout_toRightOf="@+id/tv_ID" - android:layout_below="@+id/inspect" - android:textColor="@color/colorPrimary"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="鏌ョ湅鍦板浘" - android:layout_toRightOf="@+id/tv_use_time" - android:layout_below="@+id/inspect" - android:id="@+id/view_map" - android:textColor="@color/colorPrimary"/> - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="120dp" - android:padding="5dp" - android:layout_alignParentEnd="true" - android:gravity="center" - android:orientation="vertical" - android:layout_toRightOf="@+id/view_map"> - <ImageView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - - android:src="@drawable/wheel"/> <TextView - android:layout_width="wrap_content" + android:id="@+id/tv_ID" + android:layout_width="0dp" android:layout_height="wrap_content" + android:layout_below="@+id/tv_name" android:layout_weight="1" + android:text="@string/user_id" + android:textColor="@color/colorPrimary" /> - android:text="100" - android:background="@android:color/holo_green_dark" - android:padding="8dp"/> <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="褰撳墠寰楀垎" + android:id="@+id/inspect" + android:layout_width="0dp" android:layout_weight="1" - /> + android:layout_height="wrap_content" + android:text="@string/inspector" + android:textColor="@color/colorPrimary" /> </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_weight="1" + android:layout_height="0dp" + > + + <TextView + android:id="@+id/tv_start_time" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:text="寮�濮嬫椂闂达細" + android:layout_weight="1" + android:textColor="@color/colorPrimary" /> + + + <TextView + android:id="@+id/tv_use_time" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + + android:text="鐢ㄦ椂:" + + android:textColor="@color/colorPrimary" /> + + <TextView + android:id="@+id/view_map" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="鏌ョ湅鍦板浘" + android:textColor="@color/colorPrimary" /> + </LinearLayout> + </LinearLayout> -</android.support.v7.widget.CardView> \ No newline at end of file + + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + + android:layout_weight="0.5" + android:gravity="center" + android:orientation="vertical" + > + + <ImageView + android:layout_width="wrap_content" + android:layout_height="0dp" + android:layout_weight="1" + + android:src="@drawable/wheel" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="0dp" + android:layout_weight="1" + android:layout_marginBottom="5dp" + android:layout_marginTop="5dp" + android:background="@android:color/holo_green_dark" + android:padding="5dp" + android:text="100" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="0dp" + android:layout_weight="1" + android:text="褰撳墠寰楀垎" /> + </LinearLayout> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 61c5984..c3574af 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -7,4 +7,6 @@ <color name="home_bg_color">#137b98</color> <color name="home_version_show">#b47242</color> + <color name="train_item_bg">#6a75be</color> + <color name="train_bg">#4aabb2</color> </resources> -- Gitblit v1.8.0