| | |
| | | import android.text.method.HideReturnsTransformationMethod; |
| | | import android.text.method.PasswordTransformationMethod; |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | |
| | | KeyboardStateObserverUtils.getKeyboardStateObserver((Activity) mContext).setKeyboardVisibilityListener(new KeyboardStateObserverUtils.OnKeyboardVisibilityListener() { |
| | | @Override |
| | | public void onKeyboardShow(int h) { |
| | | //Toast.makeText(MainActivity.this,"键盘弹出",Toast.LENGTH_SHORT).show(); |
| | | ConstraintSet cs = new ConstraintSet(); |
| | | cs.clone(viewBinding.loadingParentCl); |
| | | // (viewBinding.loadingConfirmationRl.getTop()-dip2px(h)) |
| | | |
| | | cs.connect(R.id.loading_confirmation_rl, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM, px2dip(h));// |
| | | //应用约束 |
| | | cs.applyTo(viewBinding.loadingParentCl); |
| | | |
| | | |
| | | // FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) viewBinding.loadingParentCl.getLayoutParams(); |
| | | // lp.bottomMargin = px2dip(h); |
| | | // viewBinding.loadingParentCl.setLayoutParams(lp); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | /** |
| | | * 根据手机的分辨率从 dp 的单位 转成为 px(像素) |
| | | */ |
| | | public int dip2px(float dpValue) { |
| | | private int dip2px(float dpValue) { |
| | | if (mContext == null) { |
| | | return 0; |
| | | } |
| | |
| | | /** |
| | | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp |
| | | */ |
| | | public int px2dip(float pxValue) { |
| | | private int px2dip(float pxValue) { |
| | | final float scale = mContext.getResources().getDisplayMetrics().density; |
| | | return (int) (pxValue / scale + 0.5f); |
| | | } |