Java Code Examples for android.app.Activity#addContentView()

The following examples show how to use android.app.Activity#addContentView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnityUtils.java    From react-native-unity-view with MIT License 5 votes vote down vote up
public static void addUnityViewToBackground() {
    if (unityPlayer == null) {
        return;
    }
    if (unityPlayer.getParent() != null) {
        ((ViewGroup)unityPlayer.getParent()).removeView(unityPlayer);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        unityPlayer.setZ(-1f);
    }
    final Activity activity = ((Activity)unityPlayer.getContext());
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(1, 1);
    activity.addContentView(unityPlayer, layoutParams);
}
 
Example 2
Source File: Cocos2dxEditText.java    From Example-of-Cocos2DX with MIT License 5 votes vote down vote up
public Cocos2dxEditText(final Context context) {
	super(context);
	
	this.mContext = context;
	this.mTextWatcher = new Cocos2dxTextInputWraper(context, this);
	this.setOnEditorActionListener(this.mTextWatcher);
	
	ViewGroup.LayoutParams layout =
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                                       ViewGroup.LayoutParams.WRAP_CONTENT);
	
	Activity activity = (Activity)context;
	activity.addContentView(this, layout);
}
 
Example 3
Source File: Cocos2dxEditText.java    From Example-of-Cocos2DX with MIT License 5 votes vote down vote up
public Cocos2dxEditText(final Context context) {
	super(context);
	
	this.mContext = context;
	this.mTextWatcher = new Cocos2dxTextInputWraper(context, this);
	this.setOnEditorActionListener(this.mTextWatcher);
	
	ViewGroup.LayoutParams layout =
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                                       ViewGroup.LayoutParams.WRAP_CONTENT);
	
	Activity activity = (Activity)context;
	activity.addContentView(this, layout);
}
 
Example 4
Source File: Cocos2dxEditText.java    From Earlybird with Apache License 2.0 5 votes vote down vote up
public Cocos2dxEditText(final Context context) {
	super(context);
	
	this.mContext = context;
	this.mTextWatcher = new Cocos2dxTextInputWraper(context, this);
	this.setOnEditorActionListener(this.mTextWatcher);
	
	ViewGroup.LayoutParams layout =
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                                       ViewGroup.LayoutParams.WRAP_CONTENT);
	
	Activity activity = (Activity)context;
	activity.addContentView(this, layout);
}
 
Example 5
Source File: ZenMenuBar.java    From zen4android with MIT License 5 votes vote down vote up
public void show() {
	Activity ac = (Activity) mContext;
	if (ac.findViewById(R.id.zen_menu_container) != null) {
		System.out.println("error: menu bar already exists.");
		return;
	}

	ac.addContentView(mMenuView, new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	mMenuBar.startAnimation(SlideInAnimation);
}
 
Example 6
Source File: DonateThanksHelper.java    From UTubeTV with The Unlicense 5 votes vote down vote up
public void install(Activity activity) {
  mContentView = new ContentView(activity);

  View view = mContentView.mView;
  if (view.getParent() == null) {
    activity.addContentView(view, mContentView.getLayoutParams());
  }
  view.startAnimation(inAnimation);
  if (view.getVisibility() != View.VISIBLE) {
    view.setVisibility(View.VISIBLE);
  }

  startRemoveTimer();
}
 
Example 7
Source File: SliderHelper.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
void addContentView(Activity activity) {
  activity.addContentView(container, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
}
 
Example 8
Source File: Manager.java    From TiCrouton with MIT License 4 votes vote down vote up
/**
 * Adds a {@link Crouton} to the {@link ViewParent} of it's {@link Activity}.
 *
 * @param crouton
 *     The {@link Crouton} that should be added.
 */
private void addCroutonToView(final Crouton crouton) {
  // don't add if it is already showing
  if (crouton.isShowing()) {
    return;
  }

  final View croutonView = crouton.getView();
  if (null == croutonView.getParent()) {
    ViewGroup.LayoutParams params = croutonView.getLayoutParams();
    if (null == params) {
      params = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    }
    // display Crouton in ViewGroup is it has been supplied
    if (null != crouton.getViewGroup()) {
      // TODO implement add to last position feature (need to align with how this will be requested for activity)
      if (crouton.getViewGroup() instanceof FrameLayout) {
        crouton.getViewGroup().addView(croutonView, params);
      } else {
        crouton.getViewGroup().addView(croutonView, 0, params);
      }
    } else {
      Activity activity = crouton.getActivity();
      if (null == activity || activity.isFinishing()) {
        return;
      }
      handleTranslucentActionBar((ViewGroup.MarginLayoutParams) params, activity);
      
      activity.addContentView(croutonView, params);
    }
    
    crouton.fireEvent("show");
  }

  croutonView.requestLayout(); // This is needed so the animation can use the measured with/height
  ViewTreeObserver observer = croutonView.getViewTreeObserver();
  if (null != observer) {
    observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
      @SuppressWarnings("deprecation")
@Override
      @TargetApi(16)
      public void onGlobalLayout() {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
          croutonView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
        } else {
          croutonView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }

        croutonView.startAnimation(crouton.getInAnimation());
        announceForAccessibilityCompat(crouton.getActivity(), crouton.getText());
        if (Configuration.DURATION_INFINITE != crouton.getConfiguration().durationInMilliseconds) {
          sendMessageDelayed(crouton, Messages.REMOVE_CROUTON,
              crouton.getConfiguration().durationInMilliseconds + crouton.getInAnimation().getDuration());
        }
      }
    });
  }
}
 
Example 9
Source File: SmartKeyboardManager.java    From timecat with Apache License 2.0 2 votes vote down vote up
/**
 * 开启点击外部关闭键盘的功能
 *
 * @param activity
 */
private void enableCloseKeyboardOnTouchOutside(Activity activity) {
    CloseKeyboardOnOutsideContainer frameLayout = new CloseKeyboardOnOutsideContainer(activity);
    activity.addContentView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
 
Example 10
Source File: InputMethodUtils.java    From timecat with Apache License 2.0 2 votes vote down vote up
/**
 * 开启点击外部关闭键盘的功能
 *
 * @param activity
 */
private void enableCloseKeyboardOnTouchOutside(Activity activity) {
    CloseKeyboardOnOutsideContainer frameLayout = new CloseKeyboardOnOutsideContainer(activity);
    activity.addContentView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}