https://github.com/ivacf/archi 仓库学习笔记

@bingoogolapple 2016-12-06 03:26:47发表于 bingoogolapple/bingoogolapple.github.io Android

在布局发生变化时添加动画效果

<LinearLayout android:animateLayoutChanges="true"
    ...
/>

Android LayoutAnimation 使用及扩展

Android 设置主题实现点击波纹效果

android:background="?android:attr/selectableItemBackground" 波纹有边界
android:background="?android:attr/selectableItemBackgroundBorderless" 波纹超出边界

DataBinding 绑定 EditText 事件

<EditText
    ...
    android:imeOptions="actionSearch"
    android:onEditorAction="@{viewModel.onSearchAction}"
    app:addTextChangedListener="@{viewModel.usernameEditTextWatcher}"/>

android:onEditorAction 对应 TextView.OnEditorActionListener 的 onEditorAction(TextView v, int actionId, KeyEvent event) 方法名

public boolean onSearchAction(TextView view, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_SEARCH) {
        ...
        return true;
    }
    return false;
}

public TextWatcher getUsernameEditTextWatcher() {
    return new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    };
}