这是我参与更文挑战的第1天,活动详情查看: 更文挑战
WebView加载不出Html5网页的解决方法
wvPrivatePolicy.setWebViewClient(new WebViewClient(){ // 在app内部加载网页
public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
view.loadUrl(url);
return true;
}//重写点击动作,用webview载入
});
wvPrivatePolicy.loadUrl(“http://www.lyzhongxin.cn/m/view.php?aid=101”);
WebView webView = findViewById(R.id.myWebView);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);/设置此属性,可任意比例缩放
webSettings.setLoadWithOverviewMode(true);
webSettings.setDomStorageEnabled(true);//不添加可能加载H5的页面时候出现一片空白,对某些标签的不支持webSettings.setBlockNetworkImage(true);//设置显示图片`
复制代码
android studio 拾色器
以前的版本是可以箱ps一样直接用笔可以直接进行试色,新版的as是不能的,我么可以通过快捷键进行试色;
androidx ViewPager高度无法wrap_content问题
`package com.base.emergency_bureau.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import androidx.viewpager.widget.ViewPager;
/**
- @ProjectName: an-kefu
- @Package: com.base.emergency_bureau.view
- @ClassName: WrapContentHeightViewPager
- @Description: java类作用描述
- @Author: liys
- @CreateDate: 2021/5/31 17:26
- @UpdateUser: 更新者
- @UpdateDate: 2021/5/31 17:26
- @UpdateRemark: 更新说明
- @Version: 1.0
*/
public class WrapContentHeightViewPager extends ViewPager {
/**
* Constructor
*
* @param context the context
*/
public WrapContentHeightViewPager(Context context) {
super(context);
}
/**
* Constructor
*
* @param context the context
* @param attrs the attribute set
*/
public WrapContentHeightViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
// @Override
复制代码
// protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//
// // find the first child view
// View view = getChildAt(0);
// if (view != null) {
// // measure the first child view with the specified measure spec
// view.measure(widthMeasureSpec, heightMeasureSpec);
// }
//
// setMeasuredDimension(getMeasuredWidth(), measureHeight(heightMeasureSpec, view));
// }
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = 0;
for(int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if(h > height) height = h;
}
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
/**
* Determines the height of this view
*
* @param measureSpec A measureSpec packed into an int
* @param view the base view with already measured height
*
* @return The height of the view, honoring constraints from measureSpec
*/
private int measureHeight(int measureSpec, View view) {
int result = 0;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
if (specMode == MeasureSpec.EXACTLY) {
result = specSize;
} else {
// set the height from the base view if available
if (view != null) {
result = view.getMeasuredHeight();
}
if (specMode == MeasureSpec.AT_MOST) {
result = Math.min(result, specSize);
}
}
return result;
}
复制代码
}
`