Example usage for android.widget FrameLayout FrameLayout

List of usage examples for android.widget FrameLayout FrameLayout

Introduction

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

Prototype

public FrameLayout(@NonNull Context context) 

Source Link

Usage

From source file:widgets.Graphical_Range.java

public Graphical_Range(tracerengine Trac, Activity context, String address, String name, int id, int dev_id,
        String state_key, String url, String usage, String parameters, String model_id, int update,
        int widgetSize, int session_type, int place_id, String place_type, SharedPreferences params)
        throws JSONException {
    super(context, Trac, id, name, "", usage, widgetSize, session_type, place_id, place_type, mytag, container);
    this.Tracer = Trac;
    this.address = address;
    this.url = url;
    this.dev_id = dev_id;
    this.id = id;
    this.state_key = state_key;
    this.usage = usage;
    this.update = update;
    this.wname = name;
    this.myself = this;
    this.session_type = session_type;
    this.place_id = place_id;
    this.place_type = place_type;
    this.context = context;
    stateThread = 1;/* www .  j a  v a2 s .  c o  m*/
    this.stateS = getResources().getText(R.string.State).toString();
    mytag = "Graphical_Range(" + dev_id + ")";
    this.params = params;
    login = params.getString("http_auth_username", null);
    password = params.getString("http_auth_password", null);

    //get parameters
    JSONObject jparam = new JSONObject(parameters.replaceAll(""", "\""));
    command = jparam.getString("command");
    valueMin = jparam.getInt("valueMin");
    valueMax = jparam.getInt("valueMax");
    range = valueMax - valueMin;
    scale = 100 / range;
    try {
        test_unite = jparam.getString("unit");
    } catch (JSONException e) {
        test_unite = "%";
    }
    if (test_unite == null || test_unite.length() == 0) {
        test_unite = "%";
    }
    String[] model = model_id.split("\\.");
    type = model[0];

    //linearlayout horizontal body      
    bodyPanHorizontal = new LinearLayout(context);
    bodyPanHorizontal.setLayoutParams(
            new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.CENTER_VERTICAL));
    bodyPanHorizontal.setOrientation(LinearLayout.HORIZONTAL);

    //right panel with different info and seekbars      
    rightPan = new FrameLayout(context);
    rightPan.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    rightPan.setPadding(0, 0, 10, 0);

    // panel
    leftPan = new LinearLayout(context);
    leftPan.setLayoutParams(
            new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, Gravity.BOTTOM));
    leftPan.setOrientation(LinearLayout.VERTICAL);
    leftPan.setGravity(Gravity.CENTER_VERTICAL);
    leftPan.setPadding(4, 5, 0, 0);

    state = new TextView(context);
    state.setTextColor(Color.BLACK);
    state.setPadding(20, 0, 0, 0);
    animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(1000);

    //first seekbar variator
    seekBarVaria = new SeekBar(context);
    seekBarVaria.setProgress(0);
    seekBarVaria.setMax(valueMax - valueMin);
    seekBarVaria.setLayoutParams(
            new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
    seekBarVaria.setProgressDrawable(getResources().getDrawable(R.drawable.bgseekbarvaria));
    seekBarVaria.setThumb(getResources().getDrawable(R.drawable.buttonseekbar));
    seekBarVaria.setThumbOffset(-3);
    seekBarVaria.setOnSeekBarChangeListener(this);
    seekBarVaria.setPadding(0, 0, 15, 7);

    leftPan.addView(state);
    leftPan.addView(seekBarVaria);
    rightPan.addView(leftPan);
    bodyPanHorizontal.addView(rightPan);
    super.LL_topPan.removeView(super.LL_featurePan);
    super.LL_infoPan.addView(bodyPanHorizontal);

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            /// Deprecated method to die /////////////////////////////////////////
            if (activate) {
                Tracer.d(mytag, "Handler receives a request to die ");
                //That seems to be a zombie
                removeView(LL_background);
                myself.setVisibility(GONE);
                if (container != null) {
                    container.removeView(myself);
                    container.recomputeViewAttributes(myself);
                }
                try {
                    finalize();
                } catch (Throwable t) {
                } //kill the handler thread itself
                ///////////////////////////////////////////////////////////////////
            } else {
                int new_val = 0;
                if (msg.what == 9999) {
                    //state_engine send us a signal to notify value changed
                    if (session == null)
                        return;
                    try {
                        Tracer.d(mytag,
                                "Handler receives a new value from cache_engine <" + session.getValue() + ">");
                        new_val = Integer.parseInt(session.getValue());
                    } catch (Exception e) {
                        new_val = 0;
                    }
                    //#1649
                    //Value min and max should be the limit of the widget
                    if (new_val <= valueMin) {
                        state.setText(stateS + valueMin + " " + test_unite);
                    } else if (new_val > valueMin && new_val < valueMax) {
                        state.setText(stateS + new_val + " " + test_unite);
                    } else if (new_val >= valueMax) {
                        state.setText(stateS + valueMax + " " + test_unite);
                    }
                    state.setAnimation(animation);
                    new SBAnim(seekBarVaria.getProgress(), new_val - valueMin).execute();

                } else if (msg.what == 9998) {
                    // state_engine send us a signal to notify it'll die !
                    Tracer.d(mytag, "state engine disappeared ===> Harakiri !");
                    session = null;
                    realtime = false;
                    removeView(LL_background);
                    myself.setVisibility(GONE);
                    if (container != null) {
                        container.removeView(myself);
                        container.recomputeViewAttributes(myself);
                    }
                    try {
                        finalize();
                    } catch (Throwable t) {
                    } //kill the handler thread itself
                }

            }
        }
    };
    //================================================================================
    /*
     * New mechanism to be notified by widgetupdate engine when our value is changed
     * 
     */
    WidgetUpdate cache_engine = WidgetUpdate.getInstance();
    if (cache_engine != null) {
        session = new Entity_client(dev_id, state_key, mytag, handler, session_type);
        if (Tracer.get_engine().subscribe(session)) {
            realtime = true; //we're connected to engine
            //each time our value change, the engine will call handler
            handler.sendEmptyMessage(9999); //Force to consider current value in session
        }

    }
    //================================================================================

}

From source file:org.telegram.ui.ChangePhoneActivity.java

@Override
public View createView(Context context) {
    actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override/*from   w w  w  .ja v a 2  s.c o m*/
        public void onItemClick(int id) {
            if (id == done_button) {
                views[currentViewNum].onNextPressed();
            } else if (id == -1) {
                finishFragment();
            }
        }
    });

    ActionBarMenu menu = actionBar.createMenu();
    doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));

    fragmentView = new ScrollView(context);
    ScrollView scrollView = (ScrollView) fragmentView;
    scrollView.setFillViewport(true);

    FrameLayout frameLayout = new FrameLayout(context);
    scrollView.addView(frameLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT));

    views[0] = new PhoneView(context);
    views[1] = new LoginActivitySmsView(context, 1);
    views[2] = new LoginActivitySmsView(context, 2);
    views[3] = new LoginActivitySmsView(context, 3);
    views[4] = new LoginActivitySmsView(context, 4);

    for (int a = 0; a < views.length; a++) {
        views[a].setVisibility(a == 0 ? View.VISIBLE : View.GONE);
        frameLayout.addView(views[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                a == 0 ? LayoutHelper.WRAP_CONTENT : LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT,
                AndroidUtilities.isTablet() ? 26 : 18, 30, AndroidUtilities.isTablet() ? 26 : 18, 0));
        //LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 16, 30, 16, 0)
    }

    actionBar.setTitle(views[0].getHeaderName());

    return fragmentView;
}

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

public void init() {

    // FrameLayout
    ViewGroup.LayoutParams framelayout_params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mFrameLayout = new FrameLayout(this);
    mFrameLayout.setLayoutParams(framelayout_params);

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

    // ...add to FrameLayout
    mFrameLayout.addView(edittext);/*from  ww  w  .  java2s  .co  m*/

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

    // ...add to FrameLayout
    mFrameLayout.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(mFrameLayout);
}

From source file:com.anlddev.customwidget.widget.AFragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);/*from w  w  w .  ja  v  a 2 s.c o m*/
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java

private void init(Context context) {

    this.mContext = context;
    // this mContainerView will be added when animation happened,
    // see DestroySelfSpringListener.onSpringActivate()
    mContainerView = new FrameLayout(context);

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.c_text_view, mContainerView, false);
    mContainerView.addView(view);/*from w w w.  ja v a 2  s  .c  o  m*/

    mContainerView.addView(mRevealCircle = generateRevealCircle());

    //generate and add follow circles
    if (mEnableFollowAnimation) {
        mFollowCircles = generateFollowCircles();
        for (int i = mFollowCircles.size() - 1; i >= 0; i--) {
            // note follow circles is not added in container view, is just added in this SpringFloatingActionMenu
            addView(mFollowCircles.get(i));
        }
    }

    //generate and add menuItemViews
    mMenuItemViews = generateMenuItemViews();
    for (MenuItemView menuItemView : mMenuItemViews) {
        mContainerView.addView(menuItemView);
        addOnMenuActionListener(menuItemView);
    }

    mMenuItemViews.get(0).bringToFront();
    //        addView(mContainerView);
    //add FAB
    LayoutParams fablp = Utils.createWrapParams();
    fablp.gravity = mGravity;
    addView(mFAB, fablp);

    setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    //add self to root view
    ViewGroup rootView = (ViewGroup) ((Activity) mContext).findViewById(android.R.id.content);
    rootView.addView(this);
    bringToFront();
    getViewTreeObserver().addOnGlobalLayoutListener(this);

    mFAB.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mAnimating) {
                return;
            }
            if (disableOpenMenuCapability) {
                return;
            }
            if (mOnFabClickListener != null) {
                mOnFabClickListener.onClcik();
            }
            if (mMenuOpen) {
                hideMenu();
            } else {
                showMenu();
            }
        }
    });
}

From source file:com.sb.tododemo.widgets.SavedStateFragmentTabHost.java

private void initFragmentTabHost(final Context context, final AttributeSet attrs) {

    final TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();/*from   w w  w  . ja va2 s . c  o m*/

    super.setOnTabChangedListener(this);

    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        final LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        final TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);
        tw.setOrientation(LinearLayout.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:com.honeywell.printer.indicator.TabPageIndicator.java

private void addTab(int index, CharSequence text, int iconResId) {
    final TabView tabView = new TabView(getContext());
    tabView.mIndex = index;//from  ww  w  . ja  va 2s  .c  om
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setText(text);
    if (iconResId != 0) {
        tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0);
    }

    {// view
        final FrameLayout container = new FrameLayout(getContext());
        container.addView(tabView);
        final NumView badge = new NumView(getContext());
        badge.setId(index + ID_OFFSET);
        badge.setVisibility(View.GONE);
        container.addView(badge);
        mTabLayout.addView(container, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
    }
}

From source file:com.seo.app.views.FragmentTabHost.java

private void ensureHierarchy(Context context) {
    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);/*from  w  w  w. j av a  2s  .c  o  m*/
        tw.setOrientation(TabWidget.HORIZONTAL);
        tw.setShowDividers(0);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    }
}

From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java

@Override
public void setContentView(View view) {

    if (_container == null) {
        FrameLayout container = new FrameLayout(this);
        LayoutParams layout = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT);
        container.setLayoutParams(layout);

        MBContentViewWrapper wrapper = MBApplicationFactory.getInstance().createContentViewWrapper();
        super.setContentView(wrapper.buildContentView(this, container));

        _container = container;/*from www. j  a va 2s  .co  m*/
    }

    _container.removeAllViews();
    _container.addView(view);
}

From source file:com.jinzht.pro.view.RecyclerViewHeader.java

private void setupAlignment(RecyclerView recycler) {
    if (!mAlreadyAligned) {
        //setting alignment of header
        ViewGroup.LayoutParams currentParams = getLayoutParams();
        FrameLayout.LayoutParams newHeaderParams;
        int width = ViewGroup.LayoutParams.WRAP_CONTENT;
        int height = ViewGroup.LayoutParams.WRAP_CONTENT;
        int gravity = (mReversed ? Gravity.BOTTOM : Gravity.TOP) | Gravity.CENTER_HORIZONTAL;
        if (currentParams != null) {
            newHeaderParams = new FrameLayout.LayoutParams(getLayoutParams()); //to copy all the margins
            newHeaderParams.width = width;
            newHeaderParams.height = height;
            newHeaderParams.gravity = gravity;
        } else {/*w  ww  .j ava 2  s.com*/
            newHeaderParams = new FrameLayout.LayoutParams(width, height, gravity);
        }
        RecyclerViewHeader.this.setLayoutParams(newHeaderParams);

        //setting alignment of recycler
        FrameLayout newRootParent = new FrameLayout(recycler.getContext());
        newRootParent.setLayoutParams(recycler.getLayoutParams());
        ViewParent currentParent = recycler.getParent();
        if (currentParent instanceof ViewGroup) {
            int indexWithinParent = ((ViewGroup) currentParent).indexOfChild(recycler);

            ((ViewGroup) currentParent).removeViewAt(indexWithinParent);
            recycler.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
            newRootParent.addView(recycler);
            newRootParent.addView(RecyclerViewHeader.this);
            ((ViewGroup) currentParent).addView(newRootParent, indexWithinParent);
        }
    }
}