本文整理汇总了Java中android.webkit.WebView.setHorizontalScrollBarEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.setHorizontalScrollBarEnabled方法的具体用法?Java WebView.setHorizontalScrollBarEnabled怎么用?Java WebView.setHorizontalScrollBarEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebView
的用法示例。
在下文中一共展示了WebView.setHorizontalScrollBarEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.webkit.WebView; //导入方法依赖的package包/类
private void init(){
LinearLayout layout = (LinearLayout) findViewById(R.id.Download_layout);
layout.setVisibility(View.GONE);
Intent intent = getIntent();
body = intent.getStringExtra("body");
title = intent.getStringExtra("title");
contentView = (WebView) findViewById(R.id.content_webview);
contentView.setHorizontalScrollBarEnabled(false);//水平不显示
contentView.setVerticalScrollBarEnabled(false); //垂直不显示
contentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});
contentView.setWebViewClient(new WebViewClient());
topImage = (ImageView) findViewById(R.id.top_image);
topTitle = (TextView) findViewById(R.id.top_titlt);
topSource = (TextView) findViewById(R.id.top_source);
}
示例2: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
LinearLayout webViewContainer = new LinearLayout(getContext());
webView = new WebView(getContext());
webView.setVerticalScrollBarEnabled(false);
webView.setHorizontalScrollBarEnabled(false);
webView.setWebViewClient(new DialogWebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
webView.setVisibility(View.INVISIBLE);
webView.getSettings().setSavePassword(false);
webView.getSettings().setSaveFormData(false);
webViewContainer.setPadding(margin, margin, margin, margin);
webViewContainer.addView(webView);
webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
contentFrameLayout.addView(webViewContainer);
}
示例3: createWebView
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
public WebView createWebView(WebView webView) {
//WebView.setWebContentsDebuggingEnabled(true);
//不能横向滚动
webView.setHorizontalScrollBarEnabled(false);
//不能纵向滚动
webView.setVerticalScrollBarEnabled(false);
//允许截图
webView.setDrawingCacheEnabled(true);
//屏蔽长按事件
webView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return true;
}
});
//初始化WebSettings
final WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
final String ua = settings.getUserAgentString();
settings.setUserAgentString(ua + "Latte");
//隐藏缩放控件
settings.setBuiltInZoomControls(false);
settings.setDisplayZoomControls(false);
//禁止缩放
settings.setSupportZoom(false);
//文件权限
settings.setAllowFileAccess(true);
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
settings.setAllowContentAccess(true);
//缓存相关
settings.setAppCacheEnabled(true);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
return webView;
}
示例4: init
import android.webkit.WebView; //导入方法依赖的package包/类
private void init(){
Intent intent = getIntent();
contentId = intent.getStringExtra("contentId");
contentView = (WebView) findViewById(R.id.content_webview);
contentView.setHorizontalScrollBarEnabled(false);//水平不显示
contentView.setVerticalScrollBarEnabled(false); //垂直不显示
contentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});
contentView.setWebViewClient(new WebViewClient());
topImage = (ImageView) findViewById(R.id.top_image);
topTitle = (TextView) findViewById(R.id.top_titlt);
topSource = (TextView) findViewById(R.id.top_source);
}
示例5: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
private void setUpWebView() {
mSpinner = new ProgressDialog(this);
mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
mSpinner.setMessage("Loading...");
mWebView = new WebView(this);
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new InstagramWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mAuthUrl);
mWebView.setLayoutParams(FILL);
WebSettings webSettings = mWebView.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
clearCache();
addContentView(mWebView,FILL);
}
示例6: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
/**
* Creating webview for instagram dialog login
*/
private void setUpWebView() {
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new OAuthWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mContent.addView(mWebView);
}
示例7: initSetting
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint({"JavascriptInterface"})
public void initSetting(WebView webView, Context context) {
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setUserAgentString(LetvUtils.createUA(webView.getSettings().getUserAgentString()));
webView.setVerticalScrollBarEnabled(true);
webView.setHorizontalScrollBarEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.addJavascriptInterface(new GetShareDesc(), "getShareDesc");
}
示例8: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override
/**
* When the dialog is created, we add the webview and load the authorize url.
*/
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
mProgress = new ProgressDialog(getContext());
mProgress.requestWindowFeature(Window.FEATURE_NO_TITLE);
mProgress.setMessage("Loading...");
mLayout = new LinearLayout(getContext());
mLayout.setOrientation(LinearLayout.VERTICAL);
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
//mWebView.getSettings().setSupportZoom(false);
mWebView.setLayoutParams(MATCH);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new OAuthWebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.loadUrl(mReq.getLocationUri());
mLayout.addView(mWebView);
Display display = getWindow().getWindowManager().getDefaultDisplay();
addContentView(mLayout, new FrameLayout.LayoutParams(display.getWidth() - 20, display.getHeight() - 20));
CookieSyncManager.createInstance(getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
}
示例9: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
private void setUpWebView() {
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new TwitterWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
mContent.addView(mWebView);
}
示例10: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView() {
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new FoursquareDialog.FoursquareWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mContent.addView(mWebView);
}
示例11: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint({"SetJavaScriptEnabled"})
@Override
public void onCreate() {
super.onCreate();
mWebView = new WebView(this);
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setBackgroundColor(Color.TRANSPARENT);
mWebView.getSettings().setJavaScriptEnabled(true);
{
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mHideParams = newLayoutParams(1);
final DisplayMetrics metrics = getResources().getDisplayMetrics();
final int min = Math.min(metrics.heightPixels, metrics.widthPixels);
mPlayerSize = (int) (min / metrics.density);
mParams = newLayoutParams(min);
mParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
mParams.y = getTopY(metrics);
}
final IntentFilter filter = new IntentFilter();
filter.addAction(ServiceAction.STOP);
filter.addAction(ServiceAction.SHOW);
filter.addAction(ServiceAction.HIDE);
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver = newBroadcastReceiver(), filter);
}
示例12: showWhatsNewBox
import android.webkit.WebView; //导入方法依赖的package包/类
public void showWhatsNewBox() {
AlertDialog.Builder blder = new AlertDialog.Builder(this);
blder.setIcon(R.drawable.icon);
blder.setTitle(getString(R.string.whats_new));
LayoutInflater factory = LayoutInflater.from(this);
View vWhatsNew = factory.inflate(R.layout.whats_new, null);
WebView webviewWhatsNew = (WebView)vWhatsNew.findViewById(R.id.webviewWhatsNew);
webviewWhatsNew.setVerticalScrollBarEnabled(true);
webviewWhatsNew.setHorizontalScrollBarEnabled(true);
webviewWhatsNew.getSettings().setBuiltInZoomControls(true);
Locale l = Locale.getDefault();
String strLanguage = String.format("%s-%s", l.getLanguage(), l.getCountry());
String strIndexAddr;
if (strLanguage.equals("zh-CN") || strLanguage.equals("zh-SG")) {
strIndexAddr = "file:///android_asset/zh-CN/" + WHATS_NEW_FILE_PATH + ".html";
} else if (strLanguage.equals("zh-TW") || strLanguage.equals("zh-HK")) {
strIndexAddr = "file:///android_asset/zh-TW/" + WHATS_NEW_FILE_PATH + ".html";
} else {
strIndexAddr = "file:///android_asset/en/" + WHATS_NEW_FILE_PATH + ".html";
strLanguage = "en";
}
webviewWhatsNew.loadUrl(strIndexAddr);
blder.setView(vWhatsNew);
blder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
blder.setCancelable(false);
AlertDialog alertWhatsnewDlg = blder.create();
alertWhatsnewDlg.show();
}
示例13: initView
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("NewApi")
private void initView() {
webView = (WebView) findViewById(R.id.webView);
setTitle("关于(V"+getVersionName(this)+")");
settings = webView.getSettings();
settings.setJavaScriptEnabled(true); //如果访问的页面中有Javascript,则WebView必须设置支持Javascript
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setSupportZoom(true); //支持缩放
settings.setBuiltInZoomControls(true); //支持手势缩放
settings.setDisplayZoomControls(false); //是否显示缩放按钮
// >= 19(SDK4.4)启动硬件加速,否则启动软件加速
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
settings.setLoadsImagesAutomatically(true); //支持自动加载图片
} else {
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
settings.setLoadsImagesAutomatically(false);
}
settings.setUseWideViewPort(true); //将图片调整到适合WebView的大小
settings.setLoadWithOverviewMode(true); //自适应屏幕
settings.setDomStorageEnabled(true);
settings.setSaveFormData(true);
settings.setSupportMultipleWindows(true);
settings.setAppCacheEnabled(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT); //优先使用缓存
webView.setHorizontalScrollbarOverlay(true);
webView.setHorizontalScrollBarEnabled(false);
webView.setOverScrollMode(View.OVER_SCROLL_NEVER); // 取消WebView中滚动或拖动到顶部、底部时的阴影
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); // 取消滚动条白边效果
webView.requestFocus();
webView.loadUrl("file:///android_asset/about.html");
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
}
示例14: setUpWebView
import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
LinearLayout webViewContainer = new LinearLayout(getContext());
webView = new WebView(getContext().getApplicationContext()) {
/* Prevent NPE on Motorola 2.2 devices
* See https://groups.google.com/forum/?fromgroups=#!topic/android-developers/ktbwY2gtLKQ
*/
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
try {
super.onWindowFocusChanged(hasWindowFocus);
} catch (NullPointerException e) {
}
}
};
webView.setVerticalScrollBarEnabled(false);
webView.setHorizontalScrollBarEnabled(false);
webView.setWebViewClient(new DialogWebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
webView.setVisibility(View.INVISIBLE);
webView.getSettings().setSavePassword(false);
webView.getSettings().setSaveFormData(false);
webView.setFocusable(true);
webView.setFocusableInTouchMode(true);
webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (!v.hasFocus())
{
v.requestFocus();
}
return false;
}
});
webViewContainer.setPadding(margin, margin, margin, margin);
webViewContainer.addView(webView);
webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
contentFrameLayout.addView(webViewContainer);
}
示例15: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_moodle);
Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
webView = (WebView) findViewById(R.id.web_moodle);
webSettings = webView.getSettings();
webSettings.setAppCacheEnabled(true);
//webSettings.setCacheMode(webSettings.LOAD_CACHE_ELSE_NETWORK);
webSettings.setJavaScriptEnabled(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setAllowFileAccess(true);
webView.setVerticalScrollBarEnabled(false);
webView.getSettings().setDomStorageEnabled(true);
webView.setHorizontalScrollBarEnabled(false);
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
CookieManager.getInstance().setAcceptCookie(true);
//final SharedPreferences profile = getSharedPreferences("userdata", 0);
webView.setWebViewClient(new PQClient());
webView.setWebChromeClient(new PQChromeClient());
//if SDK version is greater of 19 then activate hardware acceleration otherwise activate software acceleration
if (Build.VERSION.SDK_INT >= 19) {
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
else if(Build.VERSION.SDK_INT >=11 && Build.VERSION.SDK_INT < 19) {
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
webView.loadUrl("http://moodle.coep.org.in/moodle/login/index.php");
webView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
try {
DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(url));
/* Let's have some Cookies !!!*/
String cookies = CookieManager.getInstance().getCookie(url);
request.addRequestHeader("cookie", cookies);
//Yummy !!
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed!
final String filename = URLUtil.guessFileName(url, contentDisposition, mimetype);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
makeText(getApplicationContext(), "Downloading File", //To notify the Client that the file is being downloaded
Toast.LENGTH_LONG).show();
}
catch(SecurityException e)
{
Toast.makeText(getApplicationContext(),"Please grant the storage permission !",Toast.LENGTH_LONG).show();
}
}
});
}