카테고리 없음

autoLink, maxLine, imageView, asset활용, checkbox

surhommejk 2017. 11. 24. 10:56



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="가나다라마바사 www.ddd.com 전화번호: 010-9444-5555 surhommejk@daum.net"
android:autoLink="email|web|phone"
/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="dfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsdfsd"
android:maxLines="2"
/>

<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello world"
android:fontFamily="sans-serif-smallcaps"
android:textSize="19dp"
android:textStyle="italic"
android:layout_marginTop="16dp"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/chahong"
android:maxHeight="300dp"
android:maxWidth="300dp"
android:adjustViewBounds="true"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="전화번호 입력"
android:inputType="phone"
/>
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="merci"
/>
</LinearLayout>



public class Practice3_4_112 extends AppCompatActivity {

CheckBox cb;
TextView textView;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_practice3_4_112);

// text view 설정
textView = (TextView) findViewById(R.id.tv);
Typeface tf = Typeface.createFromAsset(getAssets(), "GodoM.ttf");
textView.setTypeface(tf);


// 체크박스 설정
cb = (CheckBox) findViewById(R.id.checkbox);
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
cb.setText("감사합니다");
} else {
cb.setText("merci");
}

}
});


} // onCreate end
} // class end