这是布局文件中的代码,主要看TextView节点
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
tools:context="com.iss.kcliu_14cauc.helloworld.LoginActivity"> <TextView
android:id="@+id/tv_hello"
android:layout_width="match_parent"
android:layout_height="match_parent" /></android.support.constraint.ConstraintLayout>
这是activity.java中的代码
public class LoginActivity extends AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
TextView helloText = (TextView) findViewById(R.id.tv_hello);
helloText.setText("你好,世界,噜噜噜");
helloText.setTextColor(0x00ff00);
helloText.setTextSize(30);
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
tools:context="com.iss.kcliu_14cauc.helloworld.LoginActivity"> <TextView
android:id="@+id/tv_hello"
android:layout_width="match_parent"
android:layout_height="match_parent" /></android.support.constraint.ConstraintLayout>
这是activity.java中的代码
public class LoginActivity extends AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
TextView helloText = (TextView) findViewById(R.id.tv_hello);
helloText.setText("你好,世界,噜噜噜");
helloText.setTextColor(0x00ff00);
helloText.setTextSize(30);
}
}
解决方案 »
- txt文件如何封入APK??
- Eclipse调试的时候LogCat自动消失,什么原因?
- 我大二,专攻 算法 还是android开发?或者嵌入式。。。蒙了
- 写网页,想在手机上显示,如何调背景图片?
- 小弟初学android,求大神帮忙
- handler消息和按钮消息的实时性问题
- cursor
- 如果将一个activity嵌入另外一个activity中,会是什么结果呢?
- 在自定义的view里面怎么写动画
- android 蓝牙4.0 BLE 为什么回调onServicesDiscovered方法返回的status参数一直是129?
- 一站式云端安卓软件开发工具的体验之路!
- java.lang.RuntimeException: Unable to start activity ComponentInfo
java代码可以改为:helloText.setTextColor(Color.parseColor("#00ff00"));
或改为引用资源文件颜色值;