Java Code Examples for android.widget.FrameLayout#addView()

The following examples show how to use android.widget.FrameLayout#addView() . 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: LabeledFieldController.java    From NexusDialog with Apache License 2.0 6 votes vote down vote up
@Override
protected View createView() {
    LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.form_labeled_element, null);
    errorView = (TextView) view.findViewById(R.id.field_error);

    TextView label = (TextView)view.findViewById(R.id.field_label);
    if (labelText == null) {
        label.setVisibility(View.GONE);
    } else {
        label.setText(labelText);
    }

    FrameLayout container = (FrameLayout)view.findViewById(R.id.field_container);
    container.addView(getFieldView());

    return view;
}
 
Example 2
Source File: BaseActivityDi.java    From demo-firebase-android with The Unlicense 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);

    LayoutInflater inflater = getLayoutInflater();
    View baseView = inflater.inflate(R.layout.activity_base, null);

    FrameLayout flBaseContainer = baseView.findViewById(R.id.flBaseContainer);
    llBaseLoading = baseView.findViewById(R.id.llBaseLoading);
    llBaseLoadingTextNoNetwork = baseView.findViewById(R.id.tvBaseNoNetwork);

    View childView = inflater.inflate(getLayout(), null);
    flBaseContainer.removeAllViews();
    flBaseContainer.addView(childView);

    setContentView(baseView);

    ButterKnife.bind(this);

    postButterInit();
}
 
Example 3
Source File: SuperAwesomeCardFragment.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

	LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
       params.gravity = Gravity.CENTER;

	FrameLayout fl = new FrameLayout(getActivity());
	fl.setLayoutParams(params);

	final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
			.getDisplayMetrics());

	TextView v = new TextView(getActivity());
	params.setMargins(margin, margin, margin, margin);
	v.setLayoutParams(params);
	v.setGravity(Gravity.CENTER);
	v.setBackgroundResource(R.drawable.view_sliding_tab_background_card);
	v.setText("CARD " + (position + 1));

	fl.addView(v);
	return fl;
}
 
Example 4
Source File: NativePageDialog.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FrameLayout view = (FrameLayout) LayoutInflater.from(getContext()).inflate(
            R.layout.dialog_with_titlebar, null);
    view.addView(mPage.getView(), 0);
    setContentView(view);

    getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(mPage.getTitle());

    ImageButton closeButton = (ImageButton) view.findViewById(R.id.close_button);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
}
 
Example 5
Source File: WebVideoActivity.java    From fvip with Apache License 2.0 6 votes vote down vote up
/** 视频播放全屏 **/
private void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // if a view already exists then immediately terminate the new one
    if (customView != null) {
        callback.onCustomViewHidden();
        return;
    }

    WebVideoActivity.this.getWindow().getDecorView();

    FrameLayout decor = (FrameLayout) getWindow().getDecorView();
    fullscreenContainer = new FullscreenHolder(WebVideoActivity.this);
    fullscreenContainer.addView(view, COVER_SCREEN_PARAMS);
    decor.addView(fullscreenContainer, COVER_SCREEN_PARAMS);
    customView = view;
    setStatusBarVisibility(false);
    customViewCallback = callback;
}
 
Example 6
Source File: VideoTextureView.java    From YCVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 添加TextureView到视图中
 * @param frameLayout               布局
 * @param textureView               textureView
 */
public void addTextureView(FrameLayout frameLayout , VideoTextureView textureView){
    frameLayout.removeView(textureView);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER);
    frameLayout.addView(textureView, 0, params);
}
 
Example 7
Source File: CourseTabsDashboardFragment.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    courseData = (EnrolledCoursesResponse) getArguments().getSerializable(Router.EXTRA_COURSE_DATA);
    if (courseData != null) {
        // The case where we have valid course data
        getActivity().setTitle(courseData.getCourse().getName());
        setHasOptionsMenu(courseData.getCourse().getCoursewareAccess().hasAccess());
        environment.getAnalyticsRegistry().trackScreenView(
                Analytics.Screens.COURSE_DASHBOARD, courseData.getCourse().getId(), null);

        if (!courseData.getCourse().getCoursewareAccess().hasAccess()) {
            final boolean auditAccessExpired = courseData.getAuditAccessExpires() != null &&
                    new Date().after(DateUtil.convertToDate(courseData.getAuditAccessExpires()));
            errorLayoutBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_dashboard_error_layout, container, false);
            errorLayoutBinding.errorMsg.setText(auditAccessExpired ? R.string.course_access_expired : R.string.course_not_started);
            return errorLayoutBinding.getRoot();
        } else {
            return super.onCreateView(inflater, container, savedInstanceState);
        }
    } else if (getArguments().getBoolean(ARG_COURSE_NOT_FOUND)) {
        // The case where we have invalid course data
        errorLayoutBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_dashboard_error_layout, container, false);
        errorLayoutBinding.errorMsg.setText(R.string.cannot_show_dashboard);
        return errorLayoutBinding.getRoot();
    } else {
        // The case where we need to fetch course's data based on its courseId
        fetchCourseById();
        final FrameLayout frameLayout = new FrameLayout(getActivity());
        frameLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        frameLayout.addView(inflater.inflate(R.layout.loading_indicator, container, false));
        return frameLayout;
    }
}
 
Example 8
Source File: Main4Activity.java    From styT with Apache License 2.0 5 votes vote down vote up
protected void addBGChild(FrameLayout frameLayout) {

        TextView mTextView = new TextView(frameLayout.getContext());
        mTextView.setText("技术由 AgentWeb 提供");
        mTextView.setTextSize(16);
        mTextView.setTextColor(Color.parseColor("#727779"));
        frameLayout.setBackgroundColor(Color.parseColor("#272b2d"));
        FrameLayout.LayoutParams mFlp = new FrameLayout.LayoutParams(-2, -2);
        mFlp.gravity = Gravity.CENTER_HORIZONTAL;
        final float scale = frameLayout.getContext().getResources().getDisplayMetrics().density;
        mFlp.topMargin = (int) (15 * scale + 0.5f);
        frameLayout.addView(mTextView, 0, mFlp);
    }
 
Example 9
Source File: TDialog.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
private void c()
{
    l = new ProgressBar((Context)c.get());
    android.widget.FrameLayout.LayoutParams layoutparams = new android.widget.FrameLayout.LayoutParams(-2, -2);
    layoutparams.gravity = 17;
    l.setLayoutParams(layoutparams);
    (new TextView((Context)c.get())).setText("test");
    k = new FrameLayout((Context)c.get());
    android.widget.FrameLayout.LayoutParams layoutparams1 = new android.widget.FrameLayout.LayoutParams(-1, -2);
    layoutparams1.bottomMargin = 40;
    layoutparams1.leftMargin = 80;
    layoutparams1.rightMargin = 80;
    layoutparams1.topMargin = 40;
    layoutparams1.gravity = 17;
    k.setLayoutParams(layoutparams1);
    k.setBackgroundResource(0x1080000);
    k.addView(l);
    android.widget.FrameLayout.LayoutParams layoutparams2 = new android.widget.FrameLayout.LayoutParams(-1, -1);
    j = new WebView((Context)c.get());
    j.setLayoutParams(layoutparams2);
    i = new FrameLayout((Context)c.get());
    layoutparams2.gravity = 17;
    i.setLayoutParams(layoutparams2);
    i.addView(j);
    i.addView(k);
    d = new WeakReference(k);
    setContentView(i);
}
 
Example 10
Source File: PullToRefreshInnerListView.java    From MagicHeaderViewPager with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleStyledAttributes(TypedArray a) {
    super.handleStyledAttributes(a);

    mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true);

    if (mListViewExtrasEnabled) {
        final FrameLayout.LayoutParams lp =
                new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT,
                        Gravity.CENTER_HORIZONTAL);

        int layoutId = a.getResourceId(R.styleable.PullToRefresh_ptrHeaderLayout, R.layout.default_pull_to_refresh_header_vertical);

        // Create Loading Views ready for use later
        FrameLayout frame = new FrameLayout(getContext());
        mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a, layoutId);
        mHeaderLoadingView.setVisibility(View.GONE);
        frame.addView(mHeaderLoadingView, lp);
        mRefreshableView.addHeaderView(frame, null, false);

        mLvFooterLoadingFrame = new FrameLayout(getContext());
        mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a, layoutId);
        mFooterLoadingView.setVisibility(View.GONE);
        mLvFooterLoadingFrame.addView(mFooterLoadingView, lp);

        /**
         * If the value for Scrolling While Refreshing hasn't been explicitly set via XML, enable Scrolling While Refreshing.
         */
        if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) {
            setScrollingWhileRefreshingEnabled(true);
        }
    }
}
 
Example 11
Source File: PullToRefreshListView.java    From ONE-Unofficial with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleStyledAttributes(TypedArray a) {
	super.handleStyledAttributes(a);

	mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true);

	if (mListViewExtrasEnabled) {
		final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
				FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL);

		// Create Loading Views ready for use later
		FrameLayout frame = new FrameLayout(getContext());
		mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a);
		mHeaderLoadingView.setVisibility(View.GONE);
		frame.addView(mHeaderLoadingView, lp);
		mRefreshableView.addHeaderView(frame, null, false);

		mLvFooterLoadingFrame = new FrameLayout(getContext());
		mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a);
		mFooterLoadingView.setVisibility(View.GONE);
		mLvFooterLoadingFrame.addView(mFooterLoadingView, lp);

		/**
		 * If the value for Scrolling While Refreshing hasn't been
		 * explicitly set via XML, enable Scrolling While Refreshing.
		 */
		if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) {
			setScrollingWhileRefreshingEnabled(true);
		}
	}
}
 
Example 12
Source File: DevAlertHintView.java    From dev-alert-android with Apache License 2.0 5 votes vote down vote up
public void attach(FrameLayout root) {
    if (root != null && getParent() == null) {
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.BOTTOM;
        params.setMargins(4, 4, 4, 4);
        root.addView(this, params);
        Animation rotationAni = AnimationUtils.loadAnimation(getContext(), R.anim.slide_in_from_bottom);
        startAnimation(rotationAni);
    }
}
 
Example 13
Source File: WXSliderNeighbor.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
protected void addSubView(View view, int index) {
    if (view == null || mAdapter == null) {
        return;
    }

    if (view instanceof WXCircleIndicator) {
        return;
    }

    FrameLayout wrapper = new FrameLayout(getContext());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER;
    view.setLayoutParams(params);
    wrapper.addView(view);
    super.addSubView(wrapper,index);
    updateAdapterScaleAndAlpha(mNeighborAlpha, mNeighborScale); // we need to set neighbor view status when added.

    view.postDelayed(WXThread.secure(new Runnable() {
        @Override
        public void run() {
            int childCountByDomTree = getNeighborChildrenCount();
            if(mAdapter.getRealCount() == childCountByDomTree || childCountByDomTree == -1) { // -1 mean failed at get child count by travel the dom tree.
                mViewPager.setPageTransformer(false, createTransformer());
            }
        }
    }), 100); // we need to set the PageTransformer when all children has been rendered.

}
 
Example 14
Source File: TextureGL.java    From opengl with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mAndroidSurface = new BasicGLSurfaceView(this);

    setContentView(R.layout.main);
    FrameLayout v = (FrameLayout) findViewById(R.id.gl_container);
    v.addView(mAndroidSurface);
    
    mFPSText = (TextView)findViewById(R.id.fps_text);
}
 
Example 15
Source File: HeaderViewRecyclerAdapter.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
private static View wrap(View src) {
    if (src.getParent() != null) {
        ((ViewGroup) src.getParent()).removeView(src);
    }
    FrameLayout frameLayout = new FrameLayout(src.getContext());
    frameLayout.setLayoutParams(
            new RecyclerView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    frameLayout.addView(src);
    return frameLayout;
}
 
Example 16
Source File: IRecoveryCallback.java    From Neptune with Apache License 2.0 5 votes vote down vote up
@Override
public void onSetContentView(Activity activity, String pkgName, String className) {
    TextView textView = new TextView(activity);
    textView.setText(R.string.under_recovery);
    FrameLayout frameLayout = new FrameLayout(activity);
    LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT, Gravity.CENTER);
    frameLayout.addView(textView, lp);
    activity.setContentView(frameLayout);
}
 
Example 17
Source File: LoadingFragment.java    From leanback-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.fragment_loading, container, false);

	FrameLayout loadingContainer = (FrameLayout) view.findViewById(R.id.fragment_loading_container);
	loadingContainer.setBackgroundColor(backgroundColor);

	progressBar = new ProgressBar(container.getContext());
	if (container instanceof FrameLayout) {
		FrameLayout.LayoutParams layoutParams =
				new FrameLayout.LayoutParams(progressWidth, progressHeight, Gravity.CENTER);
		progressBar.setLayoutParams(layoutParams);
	}

	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
		if (progressBar.getIndeterminateDrawable() != null) {
			progressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(progressColor),
					PorterDuff.Mode.SRC_IN);
		}
	} else {
		ColorStateList stateList = ColorStateList.valueOf(progressColor);
		progressBar.setIndeterminateTintMode(PorterDuff.Mode.SRC_IN);
		progressBar.setIndeterminateTintList(stateList);
		progressBar.setProgressBackgroundTintMode(PorterDuff.Mode.SRC_IN);
		progressBar.setProgressBackgroundTintList(stateList);
		progressBar.setIndeterminate(true);
	}

	loadingContainer.addView(progressBar);

	return view;
}
 
Example 18
Source File: SearchLayout.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view;

    if (viewType == ITEM_TYPE_ACTION) {
        ViewUtils.removeFromParent(mActionView);
        mActionView.setLayoutParams(new RecyclerView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        int resId;
        switch (mSearchMode) {
            default:
            case SEARCH_MODE_NORMAL:
                resId = R.string.image_search;
                break;
            case SEARCH_MODE_IMAGE:
                resId = R.string.keyword_search;
                break;
        }
        mAction.setText(resId);
        view = mActionView;
    } else {
        view = mInflater.inflate(R.layout.search_category, parent, false);
        TextView title = (TextView) view.findViewById(R.id.category_title);
        FrameLayout content = (FrameLayout) view.findViewById(R.id.category_content);
        switch (viewType) {
            case ITEM_TYPE_NORMAL:
                title.setText(R.string.search_normal);
                ViewUtils.removeFromParent(mNormalView);
                content.addView(mNormalView);
                break;
            case ITEM_TYPE_NORMAL_ADVANCE:
                title.setText(R.string.search_advance);
                ViewUtils.removeFromParent(mAdvanceView);
                content.addView(mAdvanceView);
                break;
            case ITEM_TYPE_IMAGE:
                title.setText(R.string.search_image);
                ViewUtils.removeFromParent(mImageView);
                content.addView(mImageView);
                break;
        }
    }

    return new SimpleHolder(view);
}
 
Example 19
Source File: VisibilityEventsIncrementalMountDisabledTest.java    From litho with Apache License 2.0 4 votes vote down vote up
@Test
public void
    visibilityProcessing_WhenViewIsFullyTranslatedOntoScreen_DispatchesFullImpressionEvent() {
  final TestComponent content = create(mContext).build();
  final EventHandler<FullImpressionVisibleEvent> fullImpressionHandler =
      new EventHandler<>(content, 2);

  final FrameLayout parent = new FrameLayout(mContext.getAndroidContext());
  LithoView lithoView = new LithoView(mContext);
  ComponentTree componentTree =
      ComponentTree.create(
              mContext,
              Column.create(mContext)
                  .child(
                      Wrapper.create(mContext)
                          .delegate(content)
                          .fullImpressionHandler(fullImpressionHandler)
                          .widthPx(100)
                          .heightPx(100))
                  .build())
          .incrementalMount(false)
          .layoutDiffing(false)
          .visibilityProcessing(true)
          .build();
  lithoView.setComponentTree(componentTree);
  parent.addView(
      lithoView,
      new FrameLayout.LayoutParams(
          ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
  lithoView.setTranslationY(-10);
  parent.measure(
      View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY),
      View.MeasureSpec.makeMeasureSpec(100, View.MeasureSpec.EXACTLY));
  parent.layout(0, 0, 100, 100);
  try {
    Whitebox.invokeMethod(lithoView, "onAttach");
  } catch (Exception e) {
    throw new RuntimeException(e);
  }

  assertThat(content.getDispatchedEventHandlers()).doesNotContain(fullImpressionHandler);

  lithoView.setTranslationY(-5);
  assertThat(content.getDispatchedEventHandlers()).doesNotContain(fullImpressionHandler);

  // Note: there seems to be some bug where the local visible rect is off by 1px when using
  // translation, thus this check will not work with -1
  lithoView.setTranslationY(-2);
  assertThat(content.getDispatchedEventHandlers()).doesNotContain(fullImpressionHandler);

  lithoView.setTranslationY(0);
  assertThat(content.getDispatchedEventHandlers()).contains(fullImpressionHandler);
}
 
Example 20
Source File: RecyclerTest3.java    From AndroidHeros with MIT License 3 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FrameLayout frameLayout = new FrameLayout(RecyclerTest3.this);

    mRcList = new RecyclerView(RecyclerTest3.this);
    mLayoutManager = new LinearLayoutManager(this);
    mRcList.setLayoutManager(mLayoutManager);
    mRcList.setHasFixedSize(true);
    // 设置显示动画
    mRcList.setItemAnimator(new DefaultItemAnimator());
    // 增加测试数据
    mData.add("Recycler");
    mData.add("Recycler");
    mData.add("Recycler");
    mAdapter = new RecyclerAdapter(mData);
    mRcList.setAdapter(mAdapter);

    frameLayout.addView(mRcList);
    setContentView(frameLayout);
}