<declare-styleable>の中の<attr>

<attr>を使って、複数の変数を定義していく。
styles.xmlで、

文字列customStrと整数値customIntを定義。
customStrの値は"ABCDE"
customIntの値は5とする。
問題は整数値を受け入れるViewの属性。
layout_widthとかはdpなのでintegerではなくdimensionだったりする。
activity_main.xmlで、

TextViewのtextにcustomStrはあてて、EditTextのmaxLengthにcustomIntをあててみる。
maxLengthはintegerなので。

TextViewにはcustomStrの&quot;ABCDE&quot;が反映されているし、EditTextはmaxLengthの5文字以上は入らない。
TextViewにはcustomStrの"ABCDE"が反映されているし、EditTextはmaxLengthの5文字以上は入らない。

TextViewにはcustomStrの"ABCDE"が反映されているし、EditTextはmaxLengthの5文字以上は入らない。

Sample/android/declare-styleableTag/attrTag/src/declare-styleableTag at master · bg1bgst333/Sample · GitHub