초보자입니다. 사용자 정의 EditText에 대한 XML을 정의한 다음 코드 집합을 사용하지 않고 런타임에 해당 사용자 정의 편집 텍스트를 프로그래밍 방식으로 추가하여 editText를 사용자 정의하려고합니다. 이것은 라이브러리에서 사용자 정의 버튼, 텍스트 뷰 등을 구현하는 것과 유사 할 수 있지만 내 자신의 버튼 일 수 있습니다. 이것을 접근하는 가장 좋은 방법은 무엇입니까?맞춤 편집 텍스트 정의
감사합니다.
초보자입니다. 사용자 정의 EditText에 대한 XML을 정의한 다음 코드 집합을 사용하지 않고 런타임에 해당 사용자 정의 편집 텍스트를 프로그래밍 방식으로 추가하여 editText를 사용자 정의하려고합니다. 이것은 라이브러리에서 사용자 정의 버튼, 텍스트 뷰 등을 구현하는 것과 유사 할 수 있지만 내 자신의 버튼 일 수 있습니다. 이것을 접근하는 가장 좋은 방법은 무엇입니까?맞춤 편집 텍스트 정의
감사합니다.
대체 코드는 다음과 같습니다 : 은 기본적으로이 코드는 쉽게 사용자가 글꼴 등을 정의하는
이public class MyEditText extends EditText {
public MyEditText(Context context) {
super(context);
}
public MyEditText(Context context, AttributeSet attrs) {
super(context, attrs);
parseAttributes(context, attrs);
}
public MyEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
parseAttributes(context, attrs);
}
private void parseAttributes(Context context, AttributeSet attrs) {
TypedArray values = context.obtainStyledAttributes(attrs, R.styleable.Simplified);
int typefaceValue = values.getInt(R.styleable.Simplified_typeface, 0);
values.recycle();
setTypeface(MyFontUtil.obtaintTypeface(context, typefaceValue));
}
}
는 XML
<com.my.mtetno.widget.MyEditText
android:id="@+id/uname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/lh_edit_field_without_border"
android:inputType="textEmailAddress"
android:maxLines="1"
android:overScrollMode="always"
android:textSize="@dimen/login_page_edit_text_size"
app:typeface="simplified_regular" />
당신 싶어이 위의 내 코드에서 사용되는 속성 세트 ABT 자세한 내용은 경우입니다 최고의 링크 -> http://stackoverflow.com/questions/2695646/declaring-a-custom- android-ui-element-using-xml – KOTIOS
당신을 정의 정의 글고 클래스를 만든다 확장 된 EditText 확인 : https://alinberce.wordpress.com/2012/02/20/android-edittext-with-custom-font-and-clear-button/ –
맞춤 디자인을 추가해야합니까? –
xml version = "1.0"encoding = "utf-8"?> <무 로이드 : 컬러 = "# FFFFFF"/> <모서리 로이드 : bottomLeftRadius가 = "10dp" 로이드 : bottomRightRadius가 = "10dp" 로이드 : topLeftRadius = "10dp" 안드로이드 : topRightRadius = "10dp"/> –