安卓學(xué)習(xí)筆記,ADB奇葩無(wú)法連接問(wèn)題

多個(gè)頁(yè)面返回

-多個(gè)頁(yè)面回退如A,B,C,D,從D直接跳轉(zhuǎn)到A。
-在D中設(shè)置intent.setFlags(intent.FLAG_ACTIVITY_CLEAR_TOP);
-如果A的intent為默認(rèn)的話得加上
-intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
-不加上面那句話,A會(huì)直接finish,然后重新創(chuàng)建。加上之后會(huì)走A頁(yè)面的onNewIntent()方法.

Intent intent = new Intent(activity, xxx.class);
intent.setFlags(intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
activity.startActivity(intent);  

部分機(jī)型PopupWindow彈出位置不正確的解決方法

show的時(shí)候調(diào)用,用坐標(biāo)系計(jì)算popwindow的高度不會(huì)出錯(cuò),如果直接用屏幕高度計(jì)算popwindow的高度會(huì)有偏差。并且popwindow設(shè)置虛擬鍵盤的方法會(huì)失效。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                int[] location = new int[2];
                view.getLocationOnScreen(location);
                int tempHeight = getHeight();
                setHeight(ScreenUtils.getFullActivityHeight(mContext) - location[1] - view.getHeight() - Utils.dp2px(mContext,55));
               
                showAtLocation(view, Gravity.NO_GRAVITY, location[0], location[1] + view.getHeight());
                update();
            } else {
                showAsDropDown(view, 0, 0);
                update();
            }

ADB不能用奇葩問(wèn)題

因?yàn)樾薷膌ocalhost只要重啟AS后導(dǎo)致ADB無(wú)法重新連接。把localhost修改回來(lái)就好了

html代碼沒(méi)有適配圖片不能全屏顯示

webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
webView.getSettings().setBuiltInZoomControls(true); // 顯示放大縮小
webView.getSettings().setSupportZoom(true); // 可以縮放
webView.getSettings().setJavaScriptEnabled(true);

webView.setWebViewClient(new MyWebViewClient());

private class MyWebViewClient extends WebViewClient {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            imgReset();//重置webview中img標(biāo)簽的圖片大小
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
}
/**
  * 對(duì)圖片進(jìn)行重置大小,寬度就是手機(jī)屏幕寬度,高度根據(jù)寬度比便自動(dòng)縮放    */
 private void imgReset() {
        webView.loadUrl("javascript:(function(){"
                + "var objs = document.getElementsByTagName('img'); "
                + "for(var i=0;i<objs.length;i++)  " + "{"
                + "var img = objs[i];   "
                + "    img.style.width = '100%';   "
                + "    img.style.height = 'auto';   "
                + "}" + "})()");
    }

如果頁(yè)面有EditView進(jìn)入頁(yè)面就會(huì)自動(dòng)獲取光標(biāo)??梢栽诟覆季旨觾删湓?/h1>
android:focusable="true"
android:focusableInTouchMode="true"

webview加載不出網(wǎng)頁(yè)

webView.getSettings().setDomStorageEnabled(true);
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容