在webview android中,白色屏幕部分覆盖了我的内容
我正在为android开发一个混合应用程序。 在我的代码中,我只有webview 当我尝试运行应用程序时,我得到一个白色矩形,几乎覆盖了url的所有内容 几乎什么都试过了,没有成功 这是我的MainActivity.java代码:在webview android中,白色屏幕部分覆盖了我的内容,android,webview,Android,Webview,我正在为android开发一个混合应用程序。 在我的代码中,我只有webview 当我尝试运行应用程序时,我得到一个白色矩形,几乎覆盖了url的所有内容 几乎什么都试过了,没有成功 这是我的MainActivity.java代码: public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCrea
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
// String url = "http://shop.chefnoded.co.il";
String url = "http://myurl";
WebView view = (WebView)this.findViewById((R.id.webView1));
view.setWebViewClient(new WebViewClient());
view.getSettings().setJavaScriptEnabled(true);
view.setBackgroundColor(0x00000000);
view.loadUrl(url);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
}
}
这是activity_main.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.mywv.MainActivity"
tools:ignore="MergeRootFrame"
>
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView1"
android:layout_gravity="center" />
我怎样才能去掉这个白色的长方形呢?
谢谢你嗯。。。我用我的三星Galaxy S4 API级别18测试了代码,它工作得非常完美,我怀疑这与设备或API级别有关。你有没有试着添加 android:hardwareAccelerated=false 您在清单文件中的活动,如前所述 另外,您在什么设备+API级别上测试它
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
}
这是谷歌开发工作室自动生成的部分。
移除后,白色屏幕消失。如何去除S4上的白色矩形 我不知道你们谈论的关于代码和域等的更改是如何进行的 自从我做了Kit Kat更新后,这个盒子就让人恼火。救命啊