成都网站备案查询,品牌网站建设内容框架,crm软件排行榜,上海市场监督管理局Android应用中出现软键盘遮挡住按钮如何解决发布时间#xff1a;2020-11-20 16:25:47来源#xff1a;亿速云阅读#xff1a;110作者#xff1a;LeahAndroid应用中出现软键盘遮挡住按钮如何解决#xff1f;相信很多没有经验的人对此束手无策#xff0c;为此本文总结了问题…Android应用中出现软键盘遮挡住按钮如何解决发布时间2020-11-20 16:25:47来源亿速云阅读110作者LeahAndroid应用中出现软键盘遮挡住按钮如何解决相信很多没有经验的人对此束手无策为此本文总结了问题出现的原因和解决方法通过这篇文章希望你能解决这个问题。如图实现1xmlandroid:idid/scrollviewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:fadingEdgenoneandroid:scrollbarsnoneandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationverticalandroid:layout_width100dpandroid:layout_height100dpandroid:layout_gravitycenter_horizontalandroid:layout_marginTop20dpandroid:srcmipmap/ic_loginhead/android:idid/et_usernamelogin_usernameandroid:layout_widthmatch_parentandroid:layout_height40dpandroid:layout_marginTop10dpandroid:backgroundnullandroid:hint请输入已验证手机android:inputTypenumberandroid:lines1android:maxLength11/android:layout_widthmatch_parentandroid:layout_height2pxandroid:layout_marginLeft50dpandroid:layout_marginRight50dpandroid:backgroundcolor/pating_line/android:idid/et_usernamelogin_passwordandroid:layout_widthmatch_parentandroid:layout_height40dpandroid:layout_marginTop20dpandroid:backgroundnullandroid:digits0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_?android:hint请输入密码android:inputTypetextPassword/android:layout_widthmatch_parentandroid:layout_height2pxandroid:layout_marginLeft50dpandroid:layout_marginRight50dpandroid:backgroundcolor/pating_line/android:idid/btn_usernamelogin_dologinandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_gravitycenter_horizontalandroid:layout_marginLeft50dpandroid:layout_marginRight50dpandroid:layout_marginTop30dpandroid:backgrounddrawable/btn_selecterandroid:enabledfalseandroid:text登录android:textColorcolor/white/javamScrollView(ScrollView)view.findViewById(R.id.scrollview);usernamelogin_username.setOnTouchListener(newView.OnTouchListener(){OverridepublicbooleanonTouch(Viewv,MotionEventevent){changeScrollView();returnfalse;}});usernamelogin_password.setOnTouchListener(newView.OnTouchListener(){OverridepublicbooleanonTouch(Viewv,MotionEventevent){changeScrollView();returnfalse;}});/***使ScrollView指向底部*/privatevoidchangeScrollView(){newHandler().postDelayed(newRunnable(){Overridepublicvoidrun(){mScrollView.scrollTo(0,mScrollView.getHeight());}},300);}实现2xml同上anim下新建gone.xmlandroid:fromXScale1.0android:toXScale0.0android:fromYScale1.0android:toYScale0.0android:pivotX50%android:pivotY50%android:duration500android:repeatCount0/visiable.xmlandroid:fromXScale0.0android:toXScale1.0android:fromYScale0.0android:toYScale1.0android:pivotX50%android:pivotY50%android:duration500android:repeatCount0/或者直接在代码中importandroid.os.Bundle;importandroid.os.Handler;importandroid.support.v7.app.AppCompatActivity;importandroid.view.KeyEvent;importandroid.view.MotionEvent;importandroid.view.View;importandroid.view.animation.Animation;importandroid.view.animation.AnimationSet;importandroid.view.animation.ScaleAnimation;importandroid.widget.Button;importandroid.widget.EditText;importandroid.widget.ImageView;publicclassMainActivityextendsAppCompatActivity{privateImageViewmHead;//头部ImageViewOverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mHead(ImageView)findViewById(R.id.iv_head);finalButtonbtn(Button)findViewById(R.id.btn_usernamelogin_dologin);finalEditTextet_pass(EditText)findViewById(R.id.et_usernamelogin_password);finalEditTextet_name(EditText)findViewById(R.id.et_usernamelogin_username);/***当输入被点击*/et_name.setOnTouchListener(newView.OnTouchListener(){OverridepublicbooleanonTouch(Viewv,MotionEventevent){start();returnfalse;}});btn.setEnabled(false);btn.setOnClickListener(newView.OnClickListener(){OverridepublicvoidonClick(Viewv){}});}privatevoidstart(){AnimationSetanimationSetnewAnimationSet(true);ScaleAnimationscaleAnimationnewScaleAnimation(1,0.1f,1,0.1f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);scaleAnimation.setDuration(500);animationSet.addAnimation(scaleAnimation);animationSet.setFillAfter(true);animationSet.setFillBefore(false);animationSet.setRepeatCount(0);//设置重复次数mHead.startAnimation(scaleAnimation);newHandler().postDelayed(newRunnable(){Overridepublicvoidrun(){mHead.setVisibility(View.GONE);}},500);}/***菜单、返回键响应*/OverridepublicbooleanonKeyDown(intkeyCode,KeyEventevent){//TODOAuto-generatedmethodstubif(keyCodeKeyEvent.KEYCODE_BACK){if(mHead.getVisibility()View.GONE){AnimationSetanimationSetnewAnimationSet(true);ScaleAnimationscaleAnimationnewScaleAnimation(0.1f,1f,0.1f,1f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);scaleAnimation.setDuration(500);animationSet.addAnimation(scaleAnimation);animationSet.setFillAfter(true);animationSet.setFillBefore(false);mHead.startAnimation(scaleAnimation);mHead.setVisibility(View.VISIBLE);}else{finish();}}returnfalse;}}效果呢看完上述内容你们掌握Android应用中出现软键盘遮挡住按钮如何解决的方法了吗如果还想学到更多技能或想了解更多相关内容欢迎关注亿速云行业资讯频道感谢各位的阅读