Android(安卓)硬编码
16lz
2022-04-19
public class TextViewActivity extends Activity {
// 声明TextView对象
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_textview);
// 获得TextView对象
textView = (TextView) findViewById(R.id.textView1);
String string = "TextView示例,欢迎使用!";
// 设置文本内容
textView.setText(string);
// 设置文本颜色
textView.setTextColor(Color.RED);
// 设置字体大小
textView.setTextSize(20);
// 设置文字背景
textView.setBackgroundColor(Color.BLUE);
}
}
更多相关文章
- Android(安卓)开发常用代码片段
- android1.5---2.1实现js调摄像头,调Java代码
- Android(安卓)设置字体大小和显示大小后界面混乱
- android 动态设置控件大小
- android dialog使用小结
- Android(安卓)使用AlarmManager设置闹钟
- android真机调试看不到logcat信息
- Android(安卓)随笔
- Android(安卓)Bad notification for startForeground: java.lang