TextInputLayout's
hint
とerror
に1つのテーマでカスタムスタイルを適用して、それをstyles.xmlで定義し、何らかの形でアプリケーション全体で使用する必要がありません。|アンドロイドアプリカテゴリ検索styles.xmlを使用してTextInputLayoutのテーマを変更する
のstyles.xml
:私たちはこのようなButton
ウィジェットを行うことができます
<android.support.design.widget.TextInputLayout
android:id="@+id/usernameWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/email_username"
android:textColorHint="@color/grey_text"
app:theme="@style/my_custom_style">
<style name="my_custom_style" parent="Widget.Design.TextInputLayout">
<item name="android:textColorHint">@color/success_accent</item>
<item name="android:textSize">20sp</item>
</style>
何かのように:このようにそれをインラインを追加します
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="buttonStyle">@style/my.Widget.Button</item>
<item name="android:buttonStyle">@style/my.Widget.Button</item>
</style>
<style name="my.Widget.Button" parent="@android:style/Widget.TextView">
<item name="android:gravity">center</item>
<item name="android:textSize">@dimen/some_dimen</item>
<item name="android:textAllCaps">false</item>
</style>
注:あなたは答えながら、私は現在、最後のとしてTextInputLayout
をサブクラス化を検討していますので、このことを念頭においてください。
感謝:)
'android:textColorHint'はテーマ属性ではなくスタイル属性であるため、テーマでは定義できません。代わりに 'android:textAppearance'テーマ属性を使用することを意味しましたか? 'TextInputLayout'は実際には' EditText'の代わりに 'LinearLayout'を拡張するラッパークラスであり、デフォルトのテキストアピアランスを考慮しない独自のヒント描画メカニズムを提供するため、これはどちらも機能しません。 – corsair992