要在Android中的布局中添加文字,可以使用TextView控件。以下是一个示例:
打开res/layout中的XML布局文件(例如activity_main.xml)。在布局文件中添加一个TextView控件,如下所示:<TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, World!" android:textSize="18sp" android:textColor="#000000" android:layout_marginTop="16dp"/>在Activity或Fragment中找到对应的TextView控件,并设置其文本内容,例如:TextView textView = findViewById(R.id.textView);textView.setText("Hello, Android!");这样就可以在Android布局中添加文字并显示出来了。通过调整TextView的属性,可以对文本样式、颜色、大小等进行进一步的定制。




