Example usage for android.widget FrameLayout addView

List of usage examples for android.widget FrameLayout addView

Introduction

In this page you can find the example usage for android.widget FrameLayout addView.

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:org.cocos2dx.lib.Cocos2dxFragmentActivity.java

public void init() {

    View v = null;//from   w w  w  . j  av a 2s.  c  o m
    if (useCustomContentView) {
        // Cocos2dxGLSurfaceView
        this.mGLSurfaceView = this.onCreateView();

        // Switch to supported OpenGL (ARGB888) mode on emulator
        if (isAndroidEmulator())
            this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());

        v = initLayout(this.mGLSurfaceView);
    }

    if (v != null) {
        setContentView(v);
        return;
    }

    // FrameLayout
    ViewGroup.LayoutParams framelayout_params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);
    FrameLayout framelayout = new FrameLayout(this);
    framelayout.setLayoutParams(framelayout_params);

    // Cocos2dxEditText layout
    ViewGroup.LayoutParams edittext_layout_params = new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    Cocos2dxEditText edittext = new Cocos2dxEditText(this);
    edittext.setLayoutParams(edittext_layout_params);

    // ...add to FrameLayout
    framelayout.addView(edittext);

    // Cocos2dxGLSurfaceView
    this.mGLSurfaceView = this.onCreateView();

    // ...add to FrameLayout
    framelayout.addView(this.mGLSurfaceView);

    // Switch to supported OpenGL (ARGB888) mode on emulator
    if (isAndroidEmulator())
        this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);

    this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());
    this.mGLSurfaceView.setCocos2dxEditText(edittext);

    // Set framelayout as the content view
    setContentView(framelayout);
}

From source file:sync.ess.hsb.xinwen.ui.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);// w  w w  .  j  ava2  s  .  c  om
    //   mListView = (ListView) f1.findViewById(R.id.listview);
    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.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.gh4a.fragment.PullRequestFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View listContent = super.onCreateView(inflater, container, savedInstanceState);
    View v = inflater.inflate(R.layout.pull_request, container, false);

    FrameLayout listContainer = (FrameLayout) v.findViewById(R.id.list_container);
    listContainer.addView(listContent);

    mImageGetter = new HttpImageGetter(inflater.getContext());
    updateCommentSectionVisibility(v);// www  . jav a2s . co  m

    return v;
}

From source file:gr.plushost.prototypeapp.widgets.LabelView.java

private boolean replaceLayout(View target) {
    if (getParent() != null || target == null || target.getParent() == null || _labelViewContainerID != -1) {
        return false;
    }//w w  w  .j a v a2s.c om

    ViewGroup parentContainer = (ViewGroup) target.getParent();

    if (target.getParent() instanceof FrameLayout) {
        ((FrameLayout) target.getParent()).addView(this);
    } else if (target.getParent() instanceof ViewGroup) {

        int groupIndex = parentContainer.indexOfChild(target);
        _labelViewContainerID = generateViewId();

        // relativeLayout need copy rule
        if (target.getParent() instanceof RelativeLayout) {
            for (int i = 0; i < parentContainer.getChildCount(); i++) {
                if (i == groupIndex) {
                    continue;
                }
                View view = parentContainer.getChildAt(i);
                RelativeLayout.LayoutParams para = (RelativeLayout.LayoutParams) view.getLayoutParams();
                for (int j = 0; j < para.getRules().length; j++) {
                    if (para.getRules()[j] == target.getId()) {
                        para.getRules()[j] = _labelViewContainerID;
                    }
                }
                view.setLayoutParams(para);
            }
        }
        parentContainer.removeView(target);

        // new dummy layout
        FrameLayout labelViewContainer = new FrameLayout(getContext());
        ViewGroup.LayoutParams targetLayoutParam = target.getLayoutParams();
        labelViewContainer.setLayoutParams(targetLayoutParam);
        target.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        // add target and label in dummy layout
        labelViewContainer.addView(target);
        labelViewContainer.addView(this);
        labelViewContainer.setId(_labelViewContainerID);

        // add dummy layout in parent container
        parentContainer.addView(labelViewContainer, groupIndex, targetLayoutParam);
    }
    return true;
}

From source file:com.launcher.silverfish.HomeScreenFragment.java

private void placeWidget(AppWidgetHostView hostView) {
    FrameLayout widget_area = (FrameLayout) rootView.findViewById(R.id.widget_area);

    widget_area.removeAllViews();/*  w  w w  .  j ava2 s.c  o m*/
    widget_area.addView(hostView);

    // Let the widget host view take control of the long click action.
    hostView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            selectWidget();
            return true;
        }
    });

    hostView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            switch (MotionEventCompat.getActionMasked(event)) {
            case MotionEvent.ACTION_DOWN:
                updateTouchDown(event);
                break;

            case MotionEvent.ACTION_MOVE:
                tryConsumeSwipe(event);
                break;
            }

            return touchConsumed;
        }
    });
}

From source file:agronet.mpayer.zegetech.com.mpayercashbox.fragments.HomeMenuFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    switch (position) {
    case 0://from www.  j  a  v a  2 s .  c  o  m
        View view = inflater.inflate(R.layout.fragment_home, container, false);

        TextView tv = (TextView) view.findViewById(R.id.orders);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnOrders = (ImageView) view.findViewById(R.id.ordersBtn);
        btnOrders.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), OrdersActivity.class);
                startActivity(i);
            }
        });
        tv = (TextView) view.findViewById(R.id.transactions);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnTransactions = (ImageView) view.findViewById(R.id.transactionsBtn);
        btnTransactions.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), TransactionsActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.accounts);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnAccounts = (ImageView) view.findViewById(R.id.accountsBtn);
        btnAccounts.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), AccountsActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.members);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnMembers = (ImageView) view.findViewById(R.id.membersBtn);
        btnMembers.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), MembersActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.reports);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnReports = (ImageView) view.findViewById(R.id.reportsBtn);
        btnReports.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), ReportsActivity.class);
                startActivity(i);
            }
        });

        tv = (TextView) view.findViewById(R.id.settings);
        tv.setTypeface(Constants.getCustomFace(getActivity(), "Open"));

        ImageView btnSettings = (ImageView) view.findViewById(R.id.settingsBtn);
        btnSettings.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getActivity(), SettingsActivity.class);
                startActivity(i);
            }
        });
        return view;
    case 1:
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        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.setLayoutParams(params);
        v.setGravity(Gravity.CENTER);
        v.setText("LOG");

        fl.addView(v);
        return fl;
    }
    return null;
}

From source file:com.alexive.graphicalutils.view.CardBuilder.java

public CardView build(Context context, CardView mCardView, boolean overrideBackground,
        boolean overrideElevation, boolean overrideRadius) {
    if (!mCardView.getTag(CARD_TYPE_TAG).equals(mCardType))
        throw new IllegalArgumentException("Attempting to recycle a card of another type.");
    LinkedList<TextView> textViews = new LinkedList<>();
    View view = mCardView.findViewById(android.R.id.text1);
    if (view != null) {
        view.setTag(true);/*w  w w . jav  a 2 s  . co m*/
        textViews.add(((TextView) view));
        ((TextView) view).setText(title);
        view.setVisibility(title != null ? View.VISIBLE : View.GONE);
    }

    view = mCardView.findViewById(android.R.id.text2);
    if (view != null) {
        textViews.add(((TextView) view));
        ((TextView) view).setText(subTitle);
        view.setVisibility(subTitle != null ? View.VISIBLE : View.GONE);
    }

    view = mCardView.findViewById(R.id.content);
    if (view != null) {
        textViews.add(((TextView) view));
        ((TextView) view).setText(text);
        view.setVisibility(text != null ? View.VISIBLE : View.GONE);
    }

    mCardView.setOnClickListener(mPrimaryAction);
    //TODO add the custom view
    FrameLayout mCustomViewParent = (FrameLayout) mCardView.findViewById(R.id.custom_view_container);
    if (mCustomViewParent != null) {
        mCustomViewParent.removeAllViews();
        if (customMainView != null)
            mCustomViewParent.addView(customMainView);
    }

    view = mCardView.findViewById(android.R.id.content);
    if (view != null) {
        if (image instanceof Bitmap)
            ((ImageView) view).setImageBitmap((Bitmap) image);
        else if (image instanceof Drawable)
            ((ImageView) view).setImageDrawable((Drawable) image);
        else
            ((ImageView) view).setImageDrawable(null);
    }

    LinearLayout mActionContainer = (LinearLayout) mCardView.findViewById(R.id.action_container);
    if (actions.isEmpty())
        mActionContainer.setVisibility(View.GONE);
    else {
        mActionContainer.setVisibility(View.VISIBLE);
        for (int i = 0; i < actions.size(); i++) {
            CardAction action = actions.get(i);
            //                int j = i;
            //                View optimalView = null;
            //              Needs to be rewriten
            //                while (j < mActionContainer.getChildCount()) {
            //                    optimalView = mActionContainer.getChildAt(j);
            //                    if ((action.drawable != null && optimalView instanceof ImageButton) || (action.title !=
            //                            null && optimalView instanceof Button)) {
            //                        mActionContainer.removeViewAt(j);
            //                        mActionContainer.addView(optimalView, i);
            //                        break;
            //                    } else {
            //                        optimalView = null;
            //                        j++;
            //                    }
            //                }
            //                if (optimalView == null) {
            View actionView = null;
            if (action.title != null) {
                Button button = (Button) LayoutInflater.from(context).inflate(R.layout.card_bttn, null);
                textViews.add(button);
                button.setText(action.title);
                button.setOnClickListener(this);
                mActionContainer.addView(button);
                actionView = button;
            } else if (action.drawable != null) {
                ImageButton imageButton = (ImageButton) LayoutInflater.from(context)
                        .inflate(R.layout.card_image_bttn, null);
                imageButton.setImageDrawable(action.drawable);
                imageButton.setOnClickListener(this);
                mActionContainer.addView(imageButton);
                actionView = imageButton;
            }

            //NASTY workaround for the padding
            View space = new View(context);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                    ViewUtils.convertDPtoPixels(context, 8), ViewUtils.convertDPtoPixels(context, 8));
            mActionContainer.addView(space, params);

            assert actionView != null;
            actionView.setTag(ACTION_ID_TAG, action);
        }
    }

    if (useLightTheme) {
        if (overrideBackground)
            mCardView.setCardBackgroundColor(0xFFFFFF);
        setTextColor(textViews, ContextCompat.getColor(context, android.R.color.primary_text_light),
                ContextCompat.getColor(context, android.R.color.secondary_text_light));

    } else {
        if (overrideBackground)
            mCardView.setCardBackgroundColor(0x424242);
        setTextColor(textViews, ContextCompat.getColor(context, android.R.color.primary_text_dark),
                ContextCompat.getColor(context, android.R.color.secondary_text_dark));
    }

    //Material design guidelines: 2dp resting elevation (or 8dp when raised)
    //Let's assume the card is resting
    //Also: 2dp corner radius
    int dPtoPixels = ViewUtils.convertDPtoPixels(context, 2);
    if (overrideElevation)
        mCardView.setCardElevation(dPtoPixels);
    if (overrideRadius)
        mCardView.setRadius(dPtoPixels);

    return mCardView;
}

From source file:com.ijiaban.tabslide.SuperAwesomeCardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    FrameLayout fl = new FrameLayout(getActivity());
    TuiJFragment TJ = new TuiJFragment();
    fl.setLayoutParams(params);//from  w  w w.j  a v  a  2s .c om

    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.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));
    getChildFragmentManager().beginTransaction().add(TJ, ARG_POSITION);
    fl.addView(v);
    return fl;
}

From source file:com.launcher.silverfish.launcher.homescreen.HomeScreenFragment.java

private void placeWidget(AppWidgetHostView hostView) {
    FrameLayout widget_area = (FrameLayout) rootView.findViewById(R.id.widget_area);

    widget_area.removeAllViews();// w w w  .j a  va  2s.c  om
    widget_area.addView(hostView);

    // Let the widget host view take control of the long click action.
    hostView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            popupSelectWidget();
            return true;
        }
    });

    hostView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            switch (MotionEventCompat.getActionMasked(event)) {
            case MotionEvent.ACTION_DOWN:
                updateTouchDown(event);
                break;

            case MotionEvent.ACTION_MOVE:
                tryConsumeSwipe(event);
                break;
            }

            return touchConsumed;
        }
    });
}

From source file:org.sufficientlysecure.keychain.gm.GmAccessibilityService.java

@SuppressLint("RtlHardcoded")
private void drawOverlay(AccessibilityNodeInfo node, View.OnClickListener onClickListener) {

    mOverlay = new FrameLayout(this);

    // must be encapsulated into FrameLayout for animation
    FrameLayout mAnimatedChild = new FrameLayout(this);
    LayoutInflater systemInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final Context contextThemeWrapper = new ContextThemeWrapper(this, R.style.FixedBottomSheetTheme);
    LayoutInflater inflater = systemInflater.cloneInContext(contextThemeWrapper);

    View child = inflater.inflate(R.layout.fixed_bottom_sheet, null);
    mAnimatedChild.addView(child);

    Button b = (Button) child.findViewById(R.id.fixed_bottom_sheet_button);
    b.setText(R.string.decrypt_with_openkeychain);
    b.setOnClickListener(onClickListener);

    ImageButton close = (ImageButton) child.findViewById(R.id.fixed_bottom_sheet_close);
    close.setOnClickListener(new View.OnClickListener() {
        @Override/*from w  w  w .j  a v  a  2s.  c o m*/
        public void onClick(View v) {
            closeOverlay();
        }
    });

    Rect webviewRect = new Rect();
    node.getBoundsInScreen(webviewRect);

    Display display = mWindowManager.getDefaultDisplay();
    Rect displayRect = new Rect();
    display.getRectSize(displayRect);

    int xpos = webviewRect.left;
    int ypos = webviewRect.top - getStatusBarHeight() < getToolbarHeight() ? getToolbarHeight()
            : webviewRect.top - getStatusBarHeight();

    int width = webviewRect.width();
    int height = webviewRect.bottom < displayRect.height()
            ? webviewRect.bottom - getToolbarHeight() - getStatusBarHeight()
            : displayRect.height() - ypos - getStatusBarHeight();

    WindowManager.LayoutParams params = new WindowManager.LayoutParams(width, height, xpos, ypos,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.windowAnimations = R.style.OverlayAnimation;
    mWindowManager.addView(mOverlay, params);
    mOverlay.addView(mAnimatedChild);
}