怎样看源码sdk

来源:互联网 发布:mac finder copy path 编辑:程序博客网 时间:2024/04/29 17:28

  每一年 谷歌都会举行 I/O大会谷歌推出了 Android Design Support Library

使用了一下TextInputLayout,想看一下源码:


路径:sdk/extras/android/support/design/libs 中将 android-support-design.jar 拷贝出来,修改拓展名为 .zip 并解压。


其实就是一个自定义View,可以看一下他的写法:

attrs.xml :

<declare-styleable name="TextInputLayout">    <attr name="hintTextAppearance" format="reference"/>    <!-- The hint to display in the floating label -->    <attr name="android:hint"/>    <!-- Whether the layout is laid out as if an error will be displayed -->    <attr name="errorEnabled" format="boolean"/>    <!-- TextAppearance of any error message displayed -->    <attr name="errorTextAppearance" format="reference"/>    <!-- Whether the layout is laid out as if the character counter will be displayed -->    <attr name="counterEnabled" format="boolean"/>    <!-- The max length to display in the character counter -->    <attr name="counterMaxLength" format="integer" />    <!-- TextAppearance of the character counter -->    <attr name="counterTextAppearance" format="reference"/>    <!-- TextAppearance of the character counter when the text is longer than the max -->    <attr name="counterOverflowTextAppearance" format="reference"/>    <attr name="android:textColorHint"/>    <!-- Whether to animate hint state changes. -->    <attr name="hintAnimationEnabled" format="boolean"/></declare-styleable>

style.xml :

<style name="TextAppearance.Design.Counter" parent="TextAppearance.AppCompat.Caption"/><style name="TextAppearance.Design.Counter.Overflow" parent="TextAppearance.AppCompat.Caption">    <item name="android:textColor">@color/design_textinput_error_color</item></style><style name="TextAppearance.Design.Error" parent="TextAppearance.AppCompat.Caption">    <item name="android:textColor">@color/design_textinput_error_color</item></style><style name="TextAppearance.Design.Hint" parent="TextAppearance.AppCompat.Caption">    <item name="android:textColor">?attr/colorControlActivated</item></style><style name="Widget.Design.TextInputLayout" parent="android:Widget">    <item name="hintTextAppearance">@style/TextAppearance.Design.Hint</item>    <item name="errorTextAppearance">@style/TextAppearance.Design.Error</item>    <item name="counterTextAppearance">@style/TextAppearance.Design.Counter</item>    <item name="counterOverflowTextAppearance">@style/TextAppearance.Design.Counter.Overflow</item></style>

colors.xml:

<color name="design_textinput_error_color">#FFDD2C00</color>

0 0
原创粉丝点击