mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
CB-8545 Don't add a layout as a parent of the WebView
Sanity checked mobilespec with --thirdpartyplugins that this doesn't break any of them.
This commit is contained in:
parent
d6da2ef096
commit
3950818030
@ -37,11 +37,10 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/**
|
||||
* This class is the main Android activity that represents the Cordova
|
||||
@ -163,31 +162,20 @@ public class CordovaActivity extends Activity {
|
||||
//Suppressing warnings in AndroidStudio
|
||||
@SuppressWarnings({"deprecation", "ResourceType"})
|
||||
protected void createViews() {
|
||||
LinearLayout root = new LinearLayout(this);
|
||||
root.setOrientation(LinearLayout.VERTICAL);
|
||||
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
|
||||
|
||||
//Why are we setting a constant as the ID? This should be investigated
|
||||
appView.getView().setId(100);
|
||||
appView.getView().setLayoutParams(new LinearLayout.LayoutParams(
|
||||
appView.getView().setLayoutParams(new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
1.0F));
|
||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
|
||||
setContentView(appView.getView());
|
||||
|
||||
// need to remove appView from any existing parent before invoking root.addView(appView)
|
||||
ViewParent parent = appView.getView().getParent();
|
||||
if ((parent != null) && (parent != root)) {
|
||||
LOG.d(TAG, "removing appView from existing parent");
|
||||
ViewGroup parentGroup = (ViewGroup) parent;
|
||||
parentGroup.removeView(appView.getView());
|
||||
if (preferences.contains("BackgroundColor")) {
|
||||
int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK);
|
||||
// Background of activity:
|
||||
appView.getView().setBackgroundColor(backgroundColor);
|
||||
}
|
||||
root.addView(appView.getView());
|
||||
setContentView(root);
|
||||
|
||||
appView.getView().requestFocusFromTouch();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user