本文整理汇总了Java中android.webkit.WebView.setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.setBackgroundColor方法的具体用法?Java WebView.setBackgroundColor怎么用?Java WebView.setBackgroundColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebView
的用法示例。
在下文中一共展示了WebView.setBackgroundColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: aboutDialog
import android.webkit.WebView; //导入方法依赖的package包/类
private void aboutDialog() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("SmartCity");
final WebView webView = new WebView(this);
String about = "<p>A Smart city , opensource weather app.</p>" +
"<p>Developed by <a href='mailto:[email protected]'>Hichem Romdhane</a></p>";
TypedArray ta = obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary, R.attr.colorAccent});
String textColor = String.format("#%06X", (0xFFFFFF & ta.getColor(0, Color.BLACK)));
String accentColor = String.format("#%06X", (0xFFFFFF & ta.getColor(1, Color.BLUE)));
ta.recycle();
about = "<style media=\"screen\" type=\"text/css\">" +
"body {\n" +
" color:" + textColor + ";\n" +
"}\n" +
"a:link {color:" + accentColor + "}\n" +
"</style>" +
about;
webView.setBackgroundColor(Color.TRANSPARENT);
webView.loadData(about, "text/html", "UTF-8");
alert.setView(webView, 32, 0, 32, 0);
alert.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.show();
}
示例2: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
getSupportActionBar().setTitle(getString(R.string.about));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
progressBar = (ProgressBar) findViewById(R.id.progress);
progressBar.getIndeterminateDrawable()
.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
info_web = (WebView) findViewById(R.id.webview_company_info);
info_web.setBackgroundColor(Color.TRANSPARENT);
info_web.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
info_web.setWebViewClient(new myWebClient());
info_web.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
info_web.getSettings().setJavaScriptEnabled(true);
info_web.getSettings().setDefaultFontSize((int) getResources().getDimension(R.dimen.about_text_size));
String infoText = getString(R.string.company_info_web);
info_web.loadDataWithBaseURL("file:///android_asset/fonts/", getWebViewText(infoText), "text/html", "utf-8", null);
}
示例3: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
getSupportActionBar().setTitle(getString(R.string.about));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
progressBar = (ProgressBar) findViewById(R.id.progress);
progressBar.getIndeterminateDrawable()
.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
info_web = (WebView) findViewById(R.id.webview_company_info);
info_web.setBackgroundColor(Color.TRANSPARENT);
info_web.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
info_web.setWebViewClient(new myWebClient());
info_web.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
info_web.getSettings().setJavaScriptEnabled(true);
String infoText = getString(R.string.company_info_web);
info_web.loadDataWithBaseURL("file:///android_asset/fonts/", getWebViewText(infoText), "text/html", "utf-8", null);
}
示例4: ViewHolder
import android.webkit.WebView; //导入方法依赖的package包/类
public ViewHolder(View layout)
{
titleAndInfo = (TextView) layout.findViewById(R.id.titleAndInfo);
aya = (TextView) layout.findViewById(R.id.aya);
tafseer = (WebView) layout.findViewById(R.id.tafseer);
tafseer.setBackgroundColor(Color.TRANSPARENT);
ayaguide = (TextView) layout.findViewById(R.id.ayaguide);
}
示例5: initWebView
import android.webkit.WebView; //导入方法依赖的package包/类
public void initWebView(WebView webView) {
webView.setVerticalScrollBarEnabled(false);
webView.setBackgroundColor(getResources().getColor(R.color.white));
//设置webview的配置
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
| WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
WebSettings webseting = webView.getSettings();
// 支持JavaScript
webseting.setJavaScriptEnabled(true);
// 支持保存数据
webseting.setSaveFormData(false);
webseting.setDomStorageEnabled(true);
// webseting.setAppCacheMaxSize(1024 * 1024 * 8);// 设置缓冲大小,我设的是8M
String appCacheDir = getApplicationContext().getDir("cache", Context.MODE_PRIVATE).getPath();
webseting.setAppCachePath(appCacheDir);
webseting.setUserAgentString(Config.FORMAT_USER_AGENT);
webseting.setLoadWithOverviewMode(true);
webseting.setUseWideViewPort(true);
webseting.setDatabaseEnabled(true);
webseting.setAllowFileAccess(true);
webseting.setCacheMode(WebSettings.LOAD_DEFAULT);
/*强制webview使用标准字号大小*/
webseting.setTextZoom(100);
// webseting.setBlockNetworkImage(true);
webseting.setLoadsImagesAutomatically(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.setWebContentsDebuggingEnabled(true);// Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application.
}
//移除webkit内部存在安全漏洞的javascript接口
webView.removeJavascriptInterface("searchBoxJavaBridge_");
webView.removeJavascriptInterface("accessibility");
webView.removeJavascriptInterface("accessibilityTraversal");
}
示例6: ViewHolder
import android.webkit.WebView; //导入方法依赖的package包/类
public ViewHolder(View layout)
{
titleAndInfo = (TextView) layout.findViewById(R.id.titleAndInfo);
aya = (TextView) layout.findViewById(R.id.aya);
tafseer = (WebView) layout.findViewById(R.id.tafseer);
tafseer.setBackgroundColor(Color.TRANSPARENT);
ayaguide = (TextView) layout.findViewById(R.id.ayaguide);
}
示例7: initLayout
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void initLayout() {
setContentView(R.layout.activity_double_tubi_player);
mTubiPlayerView = (TubiExoPlayerView) findViewById(R.id.tubitv_player);
vpaidWebView = (WebView) findViewById(R.id.vpaid_webview);
vpaidWebView.setBackgroundColor(Color.BLACK);
mTubiPlayerView.requestFocus();
mTubiPlayerView.setActivity(this);
}
示例8: onCreate
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
mHelpView = (WebView) findViewById(R.id.help_view);
mHelpView.loadDataWithBaseURL("x-data://base", getResources().getString(R.string.help_content), "text/html", "utf-8", null);
mHelpView.setBackgroundColor(Color.BLACK);
setTextSize();
}
示例9: onCreateDialog
import android.webkit.WebView; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final WebView webView = (WebView) LayoutInflater.from(getActivity()).inflate(R.layout.about_dialog, null);
final String lang = Locale.getDefault().getLanguage();
String uri = "file:///android_asset/about.html";
try {
// Load language-specific version of the about page if available.
final List<String> assets = Arrays.asList(getResources().getAssets().list(""));
if (assets.contains(String.format("about-%s.html", lang))) {
uri = String.format("file:///android_asset/about-%s.html", lang);
}
} catch (IOException e) {
e.printStackTrace();
}
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
// Getting Chromium crashes on certain KitKat devices. Might be caused by hardware acceleration
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
webView.loadUrl(uri);
webView.setBackgroundColor(Color.TRANSPARENT);
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.about)
.setView(webView)
.setPositiveButton(R.string.ok, null)
.create();
}
示例10: RuleContentVH
import android.webkit.WebView; //导入方法依赖的package包/类
public RuleContentVH(final View itemView) {
super(itemView);
mContentWV = (WebView) itemView.findViewById(R.id.wv_rule_content);
mContentWV.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
itemView.getLayoutParams().height = view.getLayoutParams().height;
itemView.requestLayout();
}
});
mContentWV.setBackgroundColor(Color.TRANSPARENT);
}
示例11: FAQContentVH
import android.webkit.WebView; //导入方法依赖的package包/类
public FAQContentVH(@NonNull final View itemView) {
super(itemView);
mContentWV = (WebView) itemView.findViewById(R.id.wv_faq_content);
mContentWV.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
itemView.getLayoutParams().height = view.getLayoutParams().height;
itemView.requestLayout();
}
});
mContentWV.setBackgroundColor(Color.TRANSPARENT);
}
示例12: initializeWebView
import android.webkit.WebView; //导入方法依赖的package包/类
private void initializeWebView(WebView webView, WebSettings webSettings) {
tashkeelOn = pageFragmentListener.getTashkeelState();
if (!tashkeelOn) page_content = ArabicUtilities.cleanTashkeel(page_content);
boolean isNightMode = pageFragmentListener.isNightMode();
if (isNightMode) webView.setBackgroundColor(0x333333);
int intialZoom = pageFragmentListener.getDisplayZoom();
webSettings.setTextZoom(intialZoom);
String data = prepareHtml(isNightMode);
loadWebView(data, webView);
}
示例13: onCreateView
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// MainFragment is the Start screen
// Since might want to alter some values in the layout we need the Inflater as a variable
View myInflater = inflater.inflate(R.layout.fragment_main, container, false);
// Adding the Github Buttons
WebView webview = (WebView) myInflater.findViewById(R.id.webViewGithub);
webview.getSettings().setJavaScriptEnabled(true);
webview.setBackgroundColor(0x00000000);
webview.loadUrl("file:///android_asset/github.html");
// If errors have been passed to the Activity they can be injected into the Fragment at this
// position. That's why we first check for errors and thereafter alter the Labels in the layout
if(getArguments().getBoolean("error")){
EditText urlInput = (EditText) myInflater.findViewById(R.id.urlInput);
urlInput.setText(getArguments().getString("originalUrl"));
TextView textViewError = (TextView) myInflater.findViewById(R.id.textViewError);
ImageView imageViewError = (ImageView) myInflater.findViewById(R.id.imageViewError);
textViewError.setText(getArguments().getString("errorMessage"));
textViewError.setVisibility(View.VISIBLE);
imageViewError.setVisibility(View.VISIBLE);
}
// Inflate the layout for this fragment
return myInflater;
}
示例14: 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);
}
示例15: onCreateView
import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_azkar_view, container, false);
zekerContainer = (WebView) rootView.findViewById(R.id.webView);
zekerContainer.getSettings().setTextSize(WebSettings.TextSize.NORMAL);
count = (ImageView) rootView.findViewById(R.id.time);
share = (ImageView) rootView.findViewById(R.id.share);
countDown = (TextView) rootView.findViewById(R.id.countDown);
count.setOnClickListener(this);
share.setOnClickListener(this);
countDown.setText(NumbersLocal.convertNumberType(getContext() , String.valueOf(getArguments().getInt(REPEAT))));
if (getArguments().getInt(REPEAT) == 1) {
count.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
count.setImageResource(R.drawable.ic_move_next);
}
content = (getArguments().getString(CONTENT));
fadl = (getArguments().getString(FADL)) == null ||
(getArguments().getString(FADL)).trim().equals("")
? "الراوى غير متوفر" : (getArguments().getString(FADL)).trim();
type = getArguments().getString(TYPE);
if (Build.VERSION.SDK_INT >= 19) {
// chromium, enable hardware acceleration
zekerContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
// older android version, disable hardware acceleration
zekerContainer.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
zekerContainer.setBackgroundColor(Color.TRANSPARENT);
zekerContainer.loadDataWithBaseURL("file:///android_asset/fonts/",
String.format("<head> <style>@font-face" +
" {font-family: 'font' ;src: url('simple.otf');}div" +
" { font-family: 'font'; word-spacing: 1px;} </style></head>" +
"<body align='justify'" +
" dir='rtl' style='line-height:1.4em ; font-size:x-large'> <div>" +
" <span style='color:#3E686A'>%s</span> <br><font size='5.5'>%s</font> </div> </body>"
, fadl, content), "text/html", "utf8", "");
return rootView;
}