官方介绍学习:https://material.google.com/ 英文版基于Material Design的登陆界面:http://sourcey.com/beautiful-android-login-and-signup-screens-with-material-design/ 翻译版基于Material Design的登陆界面:https://gold.xitu.io/entry/573bb4b6df0eea005e758f0bjava
例子中采用了Material Design的库的控件,可是具体使用细节没有写出来,容易遇到不少问题。android
解决方法: 1.在module的gradle中添加依赖git
compile 'com.android.support:appcompat-v7:24.0.0' compile 'com.android.support:design:24.0.0'
而且:修改manifest文件中Application标签下的theme:github
android:theme="@style/Theme.AppCompat">
TextInputLayout是继承于LinearLayout的容器,做用于TextView。并且,跟ScrollView同样,只能包裹一个子节点。它的效果是让Textview中的hint内容悬浮在编辑框之上,而普通textview中的hint则会被覆盖。是Android 5.0之后新加的库的控件(Android Design Support Library)。所以,须要将其library导入到项目中。因此,这就是为何第一段代码要加入的缘由。app
Theme.AppCompat Vs 普通版 AppTheme:在Android 4.0以前的Android,能够说是没有设计可言,也就是普通版AppTheme了。在4.0以后,推出了Android Design,界面有所改善,在程序实现上相应的是Holo风格(Theme.Holo.Light、Theme.Holo.Light.DarkActionBar)。为了让4.0以前的版本也兼容,就须要引入v7包, 并能使用其对应兼容的Theme.AppCompat.Light、Theme.AppCompat.Light.DarkActionBar ;而Android 5.0推出了Material Design,为了兼容,也须要引入v7包, 并可以使用其相对应兼容的Material Design Theme:Theme.AppCompat.Light、Theme.AppCompat.Light.DarkActionBar。这就是为何第二段代码须要加入。框架
Butter Knife框架是专门为Android View设计的绑定注解ide
解决方法:布局
step1:添加库依赖:性能
1.在Project的build.gradle中添加:学习
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
2.在Module的build.gradle中添加:
apply plugin: 'com.android.application' apply plugin: 'android-apt'
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:24.0.0' compile 'com.android.support:design:24.0.0' //for the butterknife compile 'com.jakewharton:butterknife:8.0.1' apt 'com.jakewharton:butterknife-compiler:8.0.1' }
step2:删除 import butterknife.InjectView,在MainActivity中添加代码:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); }
Butter Knife就是取代findViewById这样的,使用 @Bind注解并传入一个View ID,Butter Knife 就能够找到而且自动地对你的布局中的View进行转换并绑定到类成员上。相比与缓慢的反射机制,Butter Knife的代码是生成的,所以没必要担忧注解的性能问题。调用bind来生成这些代码,能够查看或调试这些代码。bug出现是由于例子中的注入方式是早些版本的,最新版本的应该按照http://jakewharton.github.io/butterknife/,以及注解文档:http://jakewharton.github.io/butterknife/javadoc/