文字に色付け
丸コピ。
エミュレータ動かすとものっそ重いので続きは明日やります。
package jp.android.helloworld; import android.app.Activity; import android.os.Bundle; import android.widget.LinearLayout; import android.view.ViewGroup; import android.widget.TextView; import android.graphics.Color; public class HelloWorld extends Activity { /** Called when the activity is first created. */ private final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT; @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); setContentView(linearLayout); TextView tv1 = new TextView(this); tv1.setText("Color Red"); tv1.setTextColor(Color.RED); linearLayout.addView(tv1, new LinearLayout.LayoutParams(WRAP_CONTENT,WRAP_CONTENT)); TextView tv2 = new TextView(this); tv2.setText("Color RGB[127, 127, 0]"); tv2.setTextColor(Color.rgb(127, 127, 0)); linearLayout.addView(tv2, new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); } }