2
많은 연구 끝에 Xml에서 사용자 지정 구성 요소를 디자인하는 방법을 찾지 못했습니다.xml로 디자인하여 사용자 지정 구성 요소 만들기
View를 상속하는 클래스를 만들어야하지만 생성자에서 일부 안드로이드 구성 요소를 사용하여 객체를 디자인하는 XML을 참조하고 싶습니다.
이것은 내가 레이아웃 폴더에 chronometer.xml 파일에 넣어보기 내용 :
<?xml version="1.0" encoding="utf-8"?>
<com.fr.loroux.minuteursimple.Chronometer
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/customChronometer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/hours"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00" />
<TextView
android:id="@+id/minutes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00" />
<TextView
android:id="@+id/seconds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00" />
</com.fr.loroux.minuteursimple.Chronometer>
하지만 지금은 생성자 클래스를 참조 할 수있는 방법? 불가능합니다.
도움 주셔서 감사합니다.
이하 :'LayoutInflater.from (context) .inflate (R.layout.chronometer, this, true); –
또는 그보다 짧 으면 마지막 'true' 매개 변수는 선택 사항이며 기본값은 false입니다. :) – kcoppock