app/src/main/java/safeluck/drive/evaluation/customview/MyCustomEditText.kt | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/drawable/input_bg.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/drawable/tv_des_bg.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/layout/layout_check_signal.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/layout/layout_mycustom_et.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/values/attrs.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
app/src/main/java/safeluck/drive/evaluation/customview/MyCustomEditText.kt
New file @@ -0,0 +1,80 @@ package safeluck.drive.evaluation.customview import android.content.Context import android.content.res.TypedArray import android.os.Parcel import android.os.Parcelable import android.text.Editable import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import android.widget.EditText import android.widget.LinearLayout import android.widget.TextView import safeluck.drive.evaluation.R /** * * @ProjectName: DriveJudge * @Package: safeluck.drive.evaluation.customview * @ClassName: MyCustomEditText * @Description: java类作用描述 * @Author: 李占伟 * @CreateDate: 2020-04-22 14:05 * @UpdateUser: 更新者 * @UpdateDate: 2020-04-22 14:05 * @UpdateRemark: 更新说明 * @Version: 1.0 */ class MyCustomEditText : LinearLayout{ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context,attrs,defStyleAttr,defStyleRes) { mcontext = context init() } // true就是显示 false不显示 var visiblity:Boolean = true var str:String="" var desstr:String="" var mcontext:Context?= null var txtDes:TextView? = null var txtDesUnit:TextView? = null var et_num:EditText? = null var view: View? = null override fun onFinishInflate() { super.onFinishInflate() txtDes = view?.findViewById(R.id.tv_des_et) txtDesUnit = view?.findViewById(R.id.tv_unit) et_num = view?.findViewById(R.id.et_num) when(visiblity){ true->txtDesUnit?.visibility = View.VISIBLE else-> txtDesUnit?.visibility = View.GONE } txtDes?.text = desstr et_num?.text = Editable.Factory.getInstance().newEditable(str) } fun init(){ view = LayoutInflater.from(mcontext).inflate(R.layout.layout_mycustom_et,null) var attributeSet = mcontext?.obtainStyledAttributes(R.styleable.mycustom_et) //获取是否要显示单位 visiblity = attributeSet?.getBoolean(R.styleable.mycustom_et_txt_unit,true)!! str = attributeSet?.getString(R.styleable.mycustom_et_txt) desstr = attributeSet?.getString(R.styleable.mycustom_et_txt_des) } } app/src/main/java/safeluck/drive/evaluation/fragment/InspectSignalFragment.java
@@ -70,8 +70,8 @@ handler.post(new Runnable() { @Override public void run() { bingding.tvRoateSpeed.setText(String.valueOf(mcuInfo.getEngine())); bingding.tvDangweiNum.setText(String.valueOf(mcuInfo.getSpeed()/10.0)); // bingding.tvRoateSpeed.setText(String.valueOf(mcuInfo.getEngine())); // bingding.tvDangweiNum.setText(String.valueOf(mcuInfo.getSpeed()/10.0)); for (int i = 0; i < gpios.size(); i++) { Log.i(TAG, "run: gpio["+i+"]="+gpios.get(i)); app/src/main/res/drawable/input_bg.xml
New file @@ -0,0 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:color="#11468A" android:width="1dp"/> <corners android:radius="5dp"/> </shape> app/src/main/res/drawable/tv_des_bg.xml
New file @@ -0,0 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#ff2b3141"/> <corners android:radius="@dimen/ui_margin_5dp"/> </shape> app/src/main/res/layout/layout_check_signal.xml
@@ -27,42 +27,10 @@ android:padding="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="70dp" android:layout_height="25dp" android:textColor="@android:color/black" android:id="@+id/tv_dangwei" android:gravity="center" android:text="@string/chesu"/> <TextView android:layout_width="35dp" android:layout_height="25dp" android:layout_toRightOf="@id/tv_dangwei" android:id="@+id/tv_dangwei_num" android:text="0" android:gravity="center" android:background="@drawable/dangwei_bg"/> <TextView android:layout_width="70dp" android:layout_height="25dp" android:textColor="@android:color/black" android:gravity="center" android:layout_marginTop="15dp" android:layout_below="@+id/tv_dangwei" android:text="@string/engine"/> <TextView android:layout_width="70dp" android:layout_height="25dp" android:gravity="center" android:layout_marginTop="15dp" android:text="-1.32332" android:id="@+id/tv_roate_speed" android:layout_toRightOf="@id/tv_dangwei" android:layout_below="@+id/tv_dangwei_num" android:background="@drawable/dangwei_bg"/> <include layout="@layout/layout_mycustom_et" android:id="@+id/myspeed" android:layout_width="200dp" android:layout_height="40dp"/> <include layout="@layout/layout_mycustom_et" android:id="@+id/myrotatespeed" android:layout_below="@+id/myspeed" android:layout_marginTop="@dimen/ui_margin_20dp" android:layout_width="237dp" android:layout_height="58dp"/> </RelativeLayout> </FrameLayout> app/src/main/res/layout/layout_mycustom_et.xml
New file @@ -0,0 +1,38 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:background="@drawable/input_bg"> <TextView android:layout_width="wrap_content" android:layout_height="58dp" android:text="车速" android:gravity="center_vertical" android:paddingLeft="@dimen/ui_margin_5dp" android:paddingRight="@dimen/ui_margin_5dp" android:textSize="20sp" android:id="@+id/tv_des_et" android:background="@drawable/tv_des_bg" android:textColor="#FFFFFF" /> <EditText android:layout_width="100dp" android:layout_height="58dp" android:text="123" android:background="@null" android:gravity="center" android:id="@+id/et_num" android:textColor="#FFFFFF" android:textSize="20sp" /> <TextView android:layout_width="wrap_content" android:layout_height="58dp" android:text="km/h" android:gravity="center" android:textSize="20sp" android:id="@+id/tv_unit" android:textColor="#888A95" /> </LinearLayout> app/src/main/res/values/attrs.xml
@@ -14,4 +14,9 @@ <declare-styleable name="HouseView"> <attr name="item" format="string" /> </declare-styleable> <declare-styleable name="mycustom_et"> <attr name="txt" format="string"/> <attr name="txt_des" format="string"/> <attr name="txt_unit" format="boolean"/> </declare-styleable> </resources>