TextInputLayout
으로 싸여진 EditText
을 사용하고 있습니다. 입력 된 텍스트 자체에 대해 textSize
을 EditText
으로 설정하면 프로그래밍 방식으로 작동합니다. 그러나 입력이 비어있을 때 표시되는 EditText
의 힌트 텍스트에는 적용되지 않습니다.TextInputLayout 내에서 EditText의 힌트 크기를 프로그래밍 방식으로 설정하십시오.
여기에 뭔가가 누락되었거나 버그입니까? 후자의 경우 해결 방법이 있습니까? 사용자 정의 View
내
TextInputLayout
:
<android.support.design.widget.TextInputLayout
android:id="@+id/password_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/default_password_hint"
android:textColorHint="@color/background_gray">
<EditText
android:id="@+id/txt_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
내가 다른 텍스트 크기와 View
을 다시 사용하려는 때문에, 나는 사용자 지정 특성을 통해 텍스트 크기를 통과
textSize
:
<declare-styleable name="PasswordInputField">
<attr name="textSize" format="dimension"/>
<attr name="hint" format="string"/>
</declare-styleable>
내 사용자 정의에 적용 다음과 같은 방법으로: TextInput 구성 레이아웃에서
if (attrs != null)
{
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PasswordInputField, 0, 0);
try
{
String hint = ta.getString(R.styleable.PasswordInputField_hint);
if (hint != null)
{
passwordInputLayout.setHint(hint);
}
float textSize = ta.getDimensionPixelSize(R.styleable.PasswordInputField_textSize, 0);
if (textSize > 0)
{
passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
}
}
finally
{
ta.recycle();
}
}
안녕하세요, 이것은 정적 시나리오에 적합한 솔루션 인 것 같습니다. 귀하의 솔루션을 동적으로 텍스트 크기를 설정해야하는 시나리오에 연결할 수 있습니까? (사용자 지정 속성을 통해 내 사용자 지정보기로 전달되기 때문에) –
이 솔루션을 사용해 보셨습니까? –
죄송합니다, 프로그래밍 방식으로 텍스트 크기를 설정해야합니다 (사용자 지정보기/텍스트 크기를 사용자 지정 특성으로 전달). 따라서 정적 솔루션이 내 문제에 어떻게 적용되는지는 알 수 없습니다. –