Android登陆页面仿拉钩平滑动画过度动效

  • 时间:
  • 浏览:2

app:leftDrawable="@drawable/google" />

}

public boolean isSoftKeyboardOpened() {

drawablePadding属性照样使用,也不设置上下左右图片的属性用自定义的吧,代码很简单,这么 了贴了。

public void addSoftKeyboardStateListener(SoftKeyboardStateListener listener) {

<com.wzh.study.login.suggest.DrawableTextView

public boolean isFullScreen(Activity activity) {

/**

return lastSoftKeyboardHeightInPx;

android:layout_centerHorizontal="true"

下面开始英文英文写登陆页面的布局,也没啥难的,就我这种方案注意几点就行:

1.把还要往上移动的布局装入 俩个容器后面 ;

2.容器的层厚计算好,给出定值;

3.登录页面设置键盘模式为:android:windowSoftInputMode="adjustResize"

4.在KeyboardWatcher.SoftKeyboardStateListener的回调接口后面 处理要处理的事,也也不平移动画之类的,看着玩耍吧!

public KeyboardWatcher(View activityRootView) {

public void onGlobalLayout() {

public int getLastSoftKeyboardHeightInPx() {

* @return last saved keyboard height in px

}

if (!isSoftKeyboardOpened &amp;&amp; heightDiff > activityRootView.getRootView().getHeight()/4) {

这种跟上次相比还俩个点也不关于显示和隐藏密码的间题:

1.发现事先项目的显示和隐藏密码是动态设置EditText的inputType来实现的,效果不太好,特别键盘抖动的赶脚。也不用了EditText的setTransformationMethod最好的办法来实现,想过都看就知道,棒棒的~

}

android:layout_height="wrap_content"

private final List<SoftKeyboardStateListener> listeners = new LinkedList<SoftKeyboardStateListener>();

}

}

}

return isSoftKeyboardOpened;

listeners.add(listener);

import android.graphics.Rect;

this.isSoftKeyboardOpened = isSoftKeyboardOpened;

private final View activityRootView;

if (listener != null) {

int resourceId = activityRootView.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android");

return (activity.getWindow().getAttributes().flags &amp;

回顾

import android.view.WindowManager;

public void removeSoftKeyboardStateListener(SoftKeyboardStateListener listener) {

import android.view.View;

效果

链接:

https://stackoverflow.com/questions/32497840/how-to-hide-ad-banner-when-opened-keyboard-on-android

}

}

private int statusBarHeight = -1;

中心思想也不activity根布局监听布局变化,实现ViewTreeObserver.OnGlobalLayoutListener接口,根据根布局层厚变化超不足英文度的1/4也不认为键盘弹起来了。链接上的人是默认层厚变化超过5000就认为键盘弹起,然后此处获取的键盘的层厚这么 减去情況栏的层厚,我改进了一下,当非全屏的事先获取的键盘层厚减去情況栏的层厚。

android:text="欢迎登陆"

2.封装了TextView的上下左右Drawable,都才能实现动态在布局文件设置大小及资源,省的在Act or Frg去设置了:

listener.onSoftKeyboardClosed();

private boolean isSoftKeyboardOpened;

}

//根据资源ID获取响应的尺寸值

this.activityRootView = activityRootView;

listeners.remove(listener);

void onSoftKeyboardClosed();

* Default value is zero {@code 0}.

}

动态效果图

listener.onSoftKeyboardOpened(keyboardHeightInPx);

public KeyboardWatcher(View activityRootView, boolean isSoftKeyboardOpened) {

@Override

}

for (SoftKeyboardStateListener listener : listeners) {

app:drawableWidth="120dp"

*/

this.lastSoftKeyboardHeightInPx = keyboardHeightInPx;

public class KeyboardWatcher implements ViewTreeObserver.OnGlobalLayoutListener {

本文作者:wenzhihao123

void onSoftKeyboardOpened(int keyboardHeightInPx);

if (listener != null) {

android:drawablePadding="10dp"

修改后的代码如下:

activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(this);

}else {

android:layout_marginTop="5000dp"

final Rect r = new Rect();

void onSoftKeyboardOpened(int keyboardHeightInPx);

事先记录过一篇实现仿拉钩特效的文章《Android登陆页面仿拉钩动效,你总会还要它!》(可点击查看),那个实现的还是占据 某些间题的,根据某些前前前前男友的反馈的情況,也不今天有时间又都看一下这种效果。今天带来相对完美某些的demo,关于键盘事件参考了Stack Overflow上以为大神的做法,在此基础上稍微修改了某些bug。

android:textStyle="bold"

statusBarHeight = activityRootView.getContext().getResources().getDimensionPixelSize(resourceId);

app:drawableHeight="40dp"

final int heightDiff = activityRootView.getRootView().getHeight() - (r.bottom - r.top);

for (SoftKeyboardStateListener listener : listeners) {

//r will be populated with the coordinates of your view that area still visible.

android:layout_width="wrap_content"

public void setIsSoftKeyboardOpened(boolean isSoftKeyboardOpened) {

isSoftKeyboardOpened = true;

}

android:gravity="center_vertical"

android:textSize="18sp"

}

private void notifyOnSoftKeyboardOpened(int keyboardHeightInPx) {

//获取status_bar_height资源的ID

}

} else if (isSoftKeyboardOpened &amp;&amp; heightDiff < activityRootView.getRootView().getHeight()/4) {

本文来自云栖社区公司公司合作 伙伴“安卓巴士Android开发者门户”,了解相关信息都才能关注“安卓巴士Android开发者门户”。

*

notifyOnSoftKeyboardClosed();

import android.view.ViewTreeObserver;

public interface SoftKeyboardStateListener {

import java.util.LinkedList;

}

isSoftKeyboardOpened = false;

private void notifyOnSoftKeyboardClosed() {

}

&amp;&amp; !isFullScreen((Activity) activityRootView.getContext())){

notifyOnSoftKeyboardOpened(heightDiff);

this.isSoftKeyboardOpened = isSoftKeyboardOpened;

private int lastSoftKeyboardHeightInPx;

notifyOnSoftKeyboardOpened(heightDiff-statusBarHeight);

}

WindowManager.LayoutParams.FLAG_FULLSCREEN)==WindowManager.LayoutParams.FLAG_FULLSCREEN;

原文发布时间为:2018-10-31

this(activityRootView, false);

android:layout_gravity="center"

}

activityRootView.getWindowVisibleDisplayFrame(r);

import android.app.Activity;

}

if ((activityRootView.getContext() instanceof Activity)

void onSoftKeyboardClosed();

android:id="@+id/logo"

if (resourceId > 0) {

}

import java.util.List;