Android学习第四天

TextView主要用于在界面上显示一段文本信息。
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#00ff00"
android:textSize="24sp"
android:text="This is TextView"/>  

 Button是程序用于和用户进行交互的一个重要控件。
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
button.setOnClickListener {
// 在此处添加逻辑

EditText是程序用于和用户进行交互的另一个重要控件,它允许用户在控件里输入和编辑内容,并
可以在程序中对这些内容进行处理。
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Type something here"
/>

ImageView是用于在界面上展示图片的一个控件,它可以让我们的程序界面变得更加丰富多彩。
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img_1"
/>

ProgressBar用于在界面上显示一个进度条,表示我们的程序正在加载一些数据。
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>

AlertDialog可以在当前界面弹出一个对话框,这个对话框是置顶于所有界面元素之上的,能够屏
蔽其他控件的交互能力,因此AlertDialog一般用于提示一些非常重要的内容或者警告信息。
AlertDialog.Builder(this).apply {
setTitle("This is Dialog")
setMessage("Something important.")
setCancelable(false)
setPositiveButton("OK") { dialog, which ->
}
setNegativeButton("Cancel") { dialog, which ->
}
show()
}

原文地址:https://www.cnblogs.com/yongyuandishen/p/14865916.html