电子说
以超薄便携USB免驱全协议NFC读写器为例,开发安卓小程序
超薄便携USB免驱全协议NFC读写器
APP的首界面:

页面代码:
使用了ConstraintLayout作为根布局。ConstraintLayout是Android开发中非常强大的一个布局管理器,它允许你以相对位置的方式定义界面中的元素,使得布局更加灵活和易于管理。下面是对这段代码的简单解释:
:这是XML声明,指定了XML的版本为1.0,编码方式为UTF-8。
:这是ConstraintLayout的根元素,它包含了布局的宽度(android:layout_width="match_parent",意味着宽度与父容器相同)、高度(android:layout_height="match_parent",意味着高度与父容器相同)以及内边距(android:padding="3dp",意味着布局内部有3dp的内边距)。
xmlns:android="http://schemas.android.com/apk/res/android":这定义了Android的命名空间,允许你使用Android框架中定义的属性和资源。
xmlns:app="http://schemas.android.com/apk/res-auto":这定义了应用的自定义命名空间,通常用于引用自定义属性或库中的属性。
xmlns:tools="http://schemas.android.com/tools":这定义了Android Studio等工具使用的命名空间,允许你在开发过程中添加一些仅在工具中可见的属性,比如布局预览时的属性。
< ?xml version="1.0" encoding="utf-8"? >
< androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="3dp"
tools:context=".MainActivity" >
< TextView
android:id="@+id/TextViewlabelGetdev"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="设备编号全球唯一,配合在设备存或读8字节功能,可做为软件加密狗用。"
android:textSize="12sp"
app:layout_constraintTop_toBottomOf="@+id/btnPcdgetdevicenumber"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" / >
< TextView
android:id="@+id/TextViewlabelDisp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="内容"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@+id/editTextDisp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/editTextDisp" / >
< EditText
android:id="@+id/editTextDisp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="@drawable/shape4border"
android:gravity="left"
android:inputType="textCapCharacters"
android:maxLength="40"
android:paddingLeft="3dp"
android:layout_marginRight="3dp"
android:text="天下英雄出我辈 一入江湖岁月催"
android:textSize="12sp"
app:layout_constraintLeft_toRightOf="@+id/TextViewlabelDisp"
app:layout_constraintRight_toLeftOf="@+id/buttonDisp"
app:layout_constraintTop_toTopOf="@+id/buttonDisp"
app:layout_constraintBottom_toBottomOf="@+id/buttonDisp"/ >
< TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请根据不同卡点击下面按键进入相应的调试页面......"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnBeep" / >
< TextView
android:id="@+id/sample_text"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:padding="3dp"
android:text="操作结果"
android:textSize="12sp"
android:background="@drawable/shape4border"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/ >
< ScrollView
android:id="@+id/scrollViewEM4305"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:scrollbars="horizontal"
android:visibility="visible"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text1"
app:layout_constraintBottom_toTopOf="@+id/sample_text"
>
< androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
< /androidx.constraintlayout.widget.ConstraintLayout >
< /ScrollView >
< /androidx.constraintlayout.widget.ConstraintLayout >
审核编辑 黄宇
全部0条评论
快来发表一下你的评论吧 !