日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

软件盘控制的问题

發布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 软件盘控制的问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

在全屏模式或者是沉寢室標題欄

方案一:全屏模式

1.軟鍵盤被EditText遮擋住了,如果說EditText被嵌套在有滑動的視圖中,采取的方式是:

activity中設置此屬性 android:windowSoftInputMode="adjustResize" 根視圖添加此屬性 android:fitsSystemWindows="true"

adjustPan是把整個界面向上平移,使輸入框露出,不會改變界面的布局

2.如果說EditText沒有被嵌套在有滑動的視圖中,采取的方式是:

activity中設置此屬性 android:windowSoftInputMode="adjustPan"
  • adjustResize則是重新計算彈出軟鍵盤之后的界面大小,相當于是用更少的界面區域去顯示內容,輸入框一般自然也就在內了。

3.如果需要進入Activity時隱藏軟件盤,采取的方式是:

android:configChanges="keyboardHidden|orientation"

方案二:

public class AndroidBug5497Workaround {// For more information, see https://code.google.com/p/android/issues/detail?id=5497// To use this class, simply invoke assistActivity() on an Activity that already has its content view set.public static void assistActivity (Activity activity) {new AndroidBug5497Workaround(activity);}private View mChildOfContent;private int usableHeightPrevious;private FrameLayout.LayoutParams frameLayoutParams;private AndroidBug5497Workaround(Activity activity) {FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);mChildOfContent = content.getChildAt(0);mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {public void onGlobalLayout() {possiblyResizeChildOfContent();}});frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();}private void possiblyResizeChildOfContent() {int usableHeightNow = computeUsableHeight();if (usableHeightNow != usableHeightPrevious) {int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();int heightDifference = usableHeightSansKeyboard - usableHeightNow;if (heightDifference > (usableHeightSansKeyboard/4)) {// keyboard probably just became visibleframeLayoutParams.height = usableHeightSansKeyboard - heightDifference;} else {// keyboard probably just became hiddenframeLayoutParams.height = usableHeightSansKeyboard;}mChildOfContent.requestLayout();usableHeightPrevious = usableHeightNow;}}private int computeUsableHeight() {Rect r = new Rect();mChildOfContent.getWindowVisibleDisplayFrame(r);return (r.bottom - r.top);// 全屏模式下: return r.bottom}}

代碼使用方式:

  • 把AndroidBug5497Workaround類復制到項目中
  • 在需要填坑的activity的onCreate方法中添加一句AndroidBug5497Workaround.assistActivity(this)即可。
  • 4.隱藏軟鍵盤

    android:clickable="true"android:focusableInTouchMode="true"

    ?

    轉載于:https://my.oschina.net/quguangle/blog/887487

    總結

    以上是生活随笔為你收集整理的软件盘控制的问题的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。