파일명 : activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="textView 연습 1" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="textView 연습 2" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="textView 연습 2" />
</LinearLayout>
파일명 : MainActivity.java
package com.example.it.myapplication4;
import android.graphics.Color;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView t1, t2, t3;
t1 = (TextView) findViewById(R.id.textView1);
t2 = (TextView) findViewById(R.id.textView2);
t3 = (TextView) findViewById(R.id.textView3);
t1.setText("안녕하세요");
t1.setTextColor(Color.RED);
t2.setTextSize(30);
t2.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD_ITALIC);
t3.setText("가나다라마바사아자차가타파하가나다라마바사아자차가타파하가나다라마바사아자차가타파하");
t3.setSingleLine();
}
}
실행화면