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:jfabrix101.lib.fragmentActivity.AbstractFragmentActivityController.java

/**
 * Crea un layout verticale utilizzando il solo fragment di sinistra (la lista)
 *//*from  ww w . java2 s  .  c  o  m*/
@SuppressWarnings("all")
protected View makeLeftPortraitLayout(LayoutInflater inflater) {
    if (getLayoutResourceId() > 0) {
        View v = LayoutInflater.from(this).inflate(getLayoutResourceId(), null);
        View rightFragment = v.findViewById(getRightFragmentId());
        if (rightFragment != null) {
            rightFragment.setVisibility(View.GONE);
        }
        mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_LEFT;
        return v;
    } else {
        LinearLayout layout = new LinearLayout(this);

        layout.setPadding(10, 10, 10, 10);
        layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        layout.setOrientation(LinearLayout.VERTICAL);

        FrameLayout leftFrame = new FrameLayout(this);
        leftFrame.setId(getLeftFragmentId());
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);
        leftFrame.setLayoutParams(lp);

        layout.addView(leftFrame);
        mVisualizationMode = VisualizationMode.PORTRAIT_ONLY_LEFT;
        return layout;
    }
}

From source file:org.solovyev.android.widget.menu.CustomPopupMenuHelper.java

private int measureContentWidth() {
    // Menus don't tend to be long, so this is more sane than it looks.
    int maxWidth = 0;
    View itemView = null;//from   w  w w  . j  a va  2 s .c o  m
    int itemType = 0;

    final ListAdapter adapter = mAdapter;
    final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final int positionType = adapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }

        if (mMeasureParent == null) {
            mMeasureParent = new FrameLayout(mContext);
        }

        itemView = adapter.getView(i, itemView, mMeasureParent);
        itemView.measure(widthMeasureSpec, heightMeasureSpec);

        final int itemWidth = itemView.getMeasuredWidth();
        if (itemWidth >= mPopupMaxWidth) {
            return mPopupMaxWidth;
        } else if (itemWidth > maxWidth) {
            maxWidth = itemWidth;
        }
    }

    return maxWidth;
}

From source file:de.localtoast.launchit.BackgroundService.java

private void initSidebar() {
    if (sidebar == null) {
        Context context = getBaseContext();
        sidebar = new FrameLayout(context);
        appListView = new AppListView(this);
        sidebar.addView(appListView);/*w w  w .j  a  v a  2s.co  m*/
        sidebar.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                /*
                 * Close the app list, when element outside of list is touched.
                 */
                if (sidebarVisible) {
                    switchToTouchArea();
                }
                return false;
            }
        });
    }
}

From source file:ti.modules.titanium.ui.widget.TiUIDrawerLayout.java

private void initRight() {
    if (rightFrame != null) {
        return;//from  ww  w.  j  a  v  a 2  s. c  om
    }
    rightFrame = new FrameLayout(proxy.getActivity());

    LayoutParams frameLayout = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    frameLayout.gravity = Gravity.END;
    rightFrame.setLayoutParams(frameLayout);

    layout.addView(rightFrame);
}

From source file:com.lixplor.rocketpulltorefresh.RefreshLayout.java

/**
 * Init header container view//from  w ww .  j a  v  a  2  s.  com
 */
private void initHeaderContainer() {
    FrameLayout headerContainer = new FrameLayout(mContext);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.width = LayoutParams.MATCH_PARENT;
    params.height = LayoutParams.WRAP_CONTENT;
    mHeaderView.measure(0, 0);
    mHeaderHeight = mHeaderView.getMeasuredHeight();
    params.topMargin = -mHeaderHeight;
    headerContainer.addView(mHeaderView);
    addView(headerContainer, 0, params);
}

From source file:com.arman.efficientqhalgoforch.SuperAwesomeCardFragment.java

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

    if (position == 2) {
        final View vv = inflater.inflate(R.layout.benchmark_lay, null);

        Button run = (Button) vv.findViewById(R.id.runAlgor);
        Button reset = (Button) vv.findViewById(R.id.cleardata);
        run.setOnClickListener(new View.OnClickListener() {
            @Override/* w ww  . j a  v  a  2  s  .com*/
            public void onClick(View v) {
                EditText thrd;
                EditText points;
                EditText canvasY;
                EditText canvasX;
                thrd = (EditText) vv.findViewById(R.id.numberTreadstxt);
                points = (EditText) vv.findViewById(R.id.numberpoints);
                canvasX = (EditText) vv.findViewById(R.id.canvasWidth);
                canvasY = (EditText) vv.findViewById(R.id.canvasHeight);
                int threads = Integer.valueOf(thrd.getText().toString());
                int ponts = Integer.valueOf(points.getText().toString());
                int canvY = Integer.valueOf(canvasY.getText().toString());
                int canvX = Integer.valueOf(canvasX.getText().toString());

                if (threads < 1)
                    threads = 1;
                if (ponts <= 2)
                    ponts = 3;
                if (threads > ponts)
                    threads = ponts - 1;
                if (threads > 25)
                    threads = 25;
                if (canvX + 100 < ponts)
                    canvX = canvX + 100;
                if (canvY + 100 < ponts)
                    canvY = canvY + 100;

                final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */,
                        Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true);

                int animTime = 10;
                final int finalThreads = threads;
                final int finalPonts = ponts;
                QuickHull qh = new QuickHull(point2DCloud, threads, true, animTime, new DoneListener() {
                    @Override
                    public void jobDone(int id, float time) {
                        mResults.add(new DataHolder(finalThreads, time, finalPonts));
                        updateChart(mResults);

                    }
                });
                qh.run();
                algorithmIndex = 2;

            }
        });

        reset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (DataHolder hld : mResults) {
                    mResults.remove(hld);
                }

                updateChart(mResults);

            }
        });
        doHardcore(vv, inflater);

        return vv;
    } else if (position == 3) {

        final View vv = inflater.inflate(R.layout.benchmark_lay, null);

        ((TextView) vv.findViewById(R.id.nametxt)).setText("             GrahamScan\n Multithreaded Benchmark");

        Button run = (Button) vv.findViewById(R.id.runAlgor);
        Button resetgr = (Button) vv.findViewById(R.id.cleardata);
        run.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EditText thrd;
                EditText points;
                EditText canvasY;
                EditText canvasX;
                thrd = (EditText) vv.findViewById(R.id.numberTreadstxt);
                points = (EditText) vv.findViewById(R.id.numberpoints);
                canvasX = (EditText) vv.findViewById(R.id.canvasWidth);
                canvasY = (EditText) vv.findViewById(R.id.canvasHeight);
                int threads = Integer.valueOf(thrd.getText().toString());
                int ponts = Integer.valueOf(points.getText().toString());
                int canvY = Integer.valueOf(canvasY.getText().toString());
                int canvX = Integer.valueOf(canvasX.getText().toString());

                if (threads < 1)
                    threads = 1;
                if (ponts <= 2)
                    ponts = 3;
                if (threads > ponts)
                    threads = ponts - 1;
                if (threads > 25)
                    threads = 25;
                if (canvX + 100 < ponts)
                    canvX = canvX + 100;
                if (canvY + 100 < ponts)
                    canvY = canvY + 100;

                final Point2DCloud point2DCloud = new Point2DCloud(getActivity(), ponts /* points */,
                        Utils.WIDTH = canvY, Utils.HEIGHT = canvX, true);

                int animTime = 10;
                final int finalThreads = threads;
                final int finalPonts = ponts;
                GrahamScanParallel gh = new GrahamScanParallel(point2DCloud, threads, true, animTime,
                        new DoneListener() {
                            @Override
                            public void jobDone(int id, float time) {
                                mGResults.add(new DataHolder(finalThreads, time, finalPonts));
                                updateChart(mGResults);

                            }
                        });
                gh.run();
                algorithmIndex = 3;

            }
        });

        resetgr.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (DataHolder hld : mGResults) {
                    mGResults.remove(hld);
                }
                updateChart(mGResults);
            }
        });
        doHardcore(vv, inflater);

        return vv;

    } else {

        if (position == 0) {

            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());

            View v = (View) inflater.inflate(R.layout.intro, null);
            params.setMargins(margin, margin, margin, margin);
            v.setLayoutParams(params);
            v.setLayoutParams(params);
            //v.setBackgroundResource(R.drawable.background_card);

            fl.addView(v);
            //fl.addView(btn);
            return fl;
        } else if (position == 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());

            View v = (View) inflater.inflate(R.layout.algo, null);
            params.setMargins(margin, margin, margin, margin);
            v.setLayoutParams(params);
            v.setLayoutParams(params);
            //v.setBackgroundResource(R.drawable.background_card);

            fl.addView(v);

            return fl;
        }

    }
    return null;
}

From source file:androidx.navigation.fragment.NavHostFragment.java

@Nullable
@Override/*from  w ww . j a va2  s.c  o  m*/
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    FrameLayout frameLayout = new FrameLayout(inflater.getContext());
    // When added via XML, this has no effect (since this FrameLayout is given the ID
    // automatically), but this ensures that the View exists as part of this Fragment's View
    // hierarchy in cases where the NavHostFragment is added programmatically as is required
    // for child fragment transactions
    frameLayout.setId(getId());
    return frameLayout;
}

From source file:org.telegram.ui.Components.StickersAlert.java

private void init(Context context) {
    shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow);

    containerView = new FrameLayout(context) {

        private int lastNotifyWidth;

        @Override/*from  w  ww .j a  va  2s . c  o m*/
        public boolean onInterceptTouchEvent(MotionEvent ev) {
            if (ev.getAction() == MotionEvent.ACTION_DOWN && scrollOffsetY != 0 && ev.getY() < scrollOffsetY) {
                dismiss();
                return true;
            }
            return super.onInterceptTouchEvent(ev);
        }

        @Override
        public boolean onTouchEvent(MotionEvent e) {
            return !isDismissed() && super.onTouchEvent(e);
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int height = MeasureSpec.getSize(heightMeasureSpec);
            if (Build.VERSION.SDK_INT >= 21) {
                height -= AndroidUtilities.statusBarHeight;
            }
            int contentSize;
            if (stickerSetCovereds != null) {
                contentSize = AndroidUtilities.dp(48 + 8) + AndroidUtilities.dp(60) * stickerSetCovereds.size()
                        + adapter.stickersRowCount * AndroidUtilities.dp(82);
            } else {
                contentSize = AndroidUtilities.dp(48 + 48) + Math.max(3,
                        (stickerSet != null ? (int) Math.ceil(stickerSet.documents.size() / 5.0f) : 0))
                        * AndroidUtilities.dp(82) + backgroundPaddingTop;
            }
            int padding = contentSize < (height / 5 * 3.2) ? 0 : (height / 5 * 2);
            if (padding != 0 && contentSize < height) {
                padding -= (height - contentSize);
            }
            if (padding == 0) {
                padding = backgroundPaddingTop;
            }
            if (stickerSetCovereds != null) {
                padding += AndroidUtilities.dp(8);
            }
            if (gridView.getPaddingTop() != padding) {
                ignoreLayout = true;
                gridView.setPadding(AndroidUtilities.dp(10), padding, AndroidUtilities.dp(10), 0);
                emptyView.setPadding(0, padding, 0, 0);
                ignoreLayout = false;
            }
            super.onMeasure(widthMeasureSpec,
                    MeasureSpec.makeMeasureSpec(Math.min(contentSize, height), MeasureSpec.EXACTLY));
        }

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            if (lastNotifyWidth != right - left) {
                lastNotifyWidth = right - left;
                if (adapter != null && stickerSetCovereds != null) {
                    adapter.notifyDataSetChanged();
                }
            }
            super.onLayout(changed, left, top, right, bottom);
            updateLayout();
        }

        @Override
        public void requestLayout() {
            if (ignoreLayout) {
                return;
            }
            super.requestLayout();
        }

        @Override
        protected void onDraw(Canvas canvas) {
            shadowDrawable.setBounds(0, scrollOffsetY - backgroundPaddingTop, getMeasuredWidth(),
                    getMeasuredHeight());
            shadowDrawable.draw(canvas);
        }
    };
    containerView.setWillNotDraw(false);
    containerView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);

    titleTextView = new TextView(context);
    titleTextView.setLines(1);
    titleTextView.setSingleLine(true);
    titleTextView.setTextColor(
            ContextCompat.getColor(context, R.color.primary_text) /*Theme.STICKERS_SHEET_TITLE_TEXT_COLOR*/);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    titleTextView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
    titleTextView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0);
    titleTextView.setGravity(Gravity.CENTER_VERTICAL);
    titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    containerView.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
    titleTextView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    shadow[0] = new View(context);
    shadow[0].setBackgroundResource(R.drawable.header_shadow);
    shadow[0].setAlpha(0.0f);
    shadow[0].setVisibility(View.INVISIBLE);
    shadow[0].setTag(1);
    containerView.addView(shadow[0],
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0));

    gridView = new RecyclerListView(context) {
        @Override
        public boolean onInterceptTouchEvent(MotionEvent event) {
            boolean result = StickerPreviewViewer.getInstance().onInterceptTouchEvent(event, gridView, 0);
            return super.onInterceptTouchEvent(event) || result;
        }

        @Override
        public void requestLayout() {
            if (ignoreLayout) {
                return;
            }
            super.requestLayout();
        }
    };
    gridView.setTag(14);
    gridView.setLayoutManager(layoutManager = new GridLayoutManager(getContext(), 5));
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            if (stickerSetCovereds != null && adapter.cache.get(position) instanceof Integer
                    || position == adapter.totalItems) {
                return adapter.stickersPerRow;
            }
            return 1;
        }
    });
    gridView.setAdapter(adapter = new GridAdapter(context));
    gridView.setVerticalScrollBarEnabled(false);
    gridView.addItemDecoration(new RecyclerView.ItemDecoration() {
        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            outRect.left = 0;
            outRect.right = 0;
            outRect.bottom = 0;
            outRect.top = 0;
        }
    });
    gridView.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), 0);
    gridView.setClipToPadding(false);
    gridView.setEnabled(true);
    gridView.setGlowColor(0xfff5f6f7);
    gridView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return StickerPreviewViewer.getInstance().onTouch(event, gridView, 0, stickersOnItemClickListener);
        }
    });
    gridView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            updateLayout();
        }
    });
    stickersOnItemClickListener = new RecyclerListView.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            if (stickerSetCovereds != null) {
                TLRPC.StickerSetCovered pack = adapter.positionsToSets.get(position);
                if (pack != null) {
                    dismiss();
                    TLRPC.TL_inputStickerSetID inputStickerSetID = new TLRPC.TL_inputStickerSetID();
                    inputStickerSetID.access_hash = pack.set.access_hash;
                    inputStickerSetID.id = pack.set.id;
                    StickersAlert alert = new StickersAlert(parentActivity, parentFragment, inputStickerSetID,
                            null, null);
                    alert.show();
                }
            } else {
                if (stickerSet == null || position < 0 || position >= stickerSet.documents.size()) {
                    return;
                }
                selectedSticker = stickerSet.documents.get(position);

                boolean set = false;
                for (int a = 0; a < selectedSticker.attributes.size(); a++) {
                    TLRPC.DocumentAttribute attribute = selectedSticker.attributes.get(a);
                    if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
                        if (attribute.alt != null && attribute.alt.length() > 0) {
                            stickerEmojiTextView.setText(Emoji.replaceEmoji(attribute.alt,
                                    stickerEmojiTextView.getPaint().getFontMetricsInt(),
                                    AndroidUtilities.dp(30), false));
                            set = true;
                        }
                        break;
                    }
                }
                if (!set) {
                    stickerEmojiTextView
                            .setText(Emoji.replaceEmoji(StickersQuery.getEmojiForSticker(selectedSticker.id),
                                    stickerEmojiTextView.getPaint().getFontMetricsInt(),
                                    AndroidUtilities.dp(30), false));
                }

                stickerImageView.getImageReceiver().setImage(selectedSticker, null,
                        selectedSticker.thumb.location, null, "webp", true);
                FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) stickerPreviewLayout
                        .getLayoutParams();
                layoutParams.topMargin = scrollOffsetY;
                stickerPreviewLayout.setLayoutParams(layoutParams);
                stickerPreviewLayout.setVisibility(View.VISIBLE);
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.playTogether(ObjectAnimator.ofFloat(stickerPreviewLayout, "alpha", 0.0f, 1.0f));
                animatorSet.setDuration(200);
                animatorSet.start();
            }
        }
    };
    gridView.setOnItemClickListener(stickersOnItemClickListener);
    containerView.addView(gridView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 48));

    emptyView = new FrameLayout(context) {
        @Override
        public void requestLayout() {
            if (ignoreLayout) {
                return;
            }
            super.requestLayout();
        }
    };
    containerView.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48));
    gridView.setEmptyView(emptyView);
    emptyView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    ProgressBar progressView = new ProgressBar(context);
    emptyView.addView(progressView,
            LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));

    shadow[1] = new View(context);
    shadow[1].setBackgroundResource(R.drawable.header_shadow_reverse);
    containerView.addView(shadow[1],
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48));

    pickerBottomLayout = new PickerBottomLayout(context, false);
    containerView.addView(pickerBottomLayout,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM));
    pickerBottomLayout.cancelButton.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0);
    pickerBottomLayout.cancelButton.setTextColor(Theme.STICKERS_SHEET_CLOSE_TEXT_COLOR);
    pickerBottomLayout.cancelButton.setText(LocaleController.getString("Close", R.string.Close).toUpperCase());
    pickerBottomLayout.cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
    pickerBottomLayout.doneButton.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0);
    pickerBottomLayout.doneButtonBadgeTextView.setBackgroundResource(R.drawable.stickercounter);

    stickerPreviewLayout = new FrameLayout(context);
    if ((context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_YES) != 0) {
        stickerPreviewLayout.setBackgroundColor(
                0x00ffffff & ContextCompat.getColor(context, R.color.card_background) | 0xdf000000);
    } else {
        stickerPreviewLayout.setBackgroundColor(0xdfffffff);
    }
    stickerPreviewLayout.setVisibility(View.GONE);
    stickerPreviewLayout.setSoundEffectsEnabled(false);
    containerView.addView(stickerPreviewLayout,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    stickerPreviewLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hidePreview();
        }
    });

    ImageView closeButton = new ImageView(context);
    closeButton.setImageResource(R.drawable.delete_reply);
    closeButton.setScaleType(ImageView.ScaleType.CENTER);
    if (Build.VERSION.SDK_INT >= 21) {
        closeButton.setBackgroundDrawable(Theme.createBarSelectorDrawable(Theme.INPUT_FIELD_SELECTOR_COLOR));
    }
    stickerPreviewLayout.addView(closeButton, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP));
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hidePreview();
        }
    });

    stickerImageView = new BackupImageView(context);
    stickerImageView.setAspectFit(true);
    stickerPreviewLayout.addView(stickerImageView);

    stickerEmojiTextView = new TextView(context);
    stickerEmojiTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 30);
    stickerEmojiTextView.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
    stickerPreviewLayout.addView(stickerEmojiTextView);

    previewSendButton = new TextView(context);
    previewSendButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    previewSendButton.setTextColor(Theme.STICKERS_SHEET_SEND_TEXT_COLOR);
    previewSendButton.setGravity(Gravity.CENTER);
    previewSendButton.setBackgroundColor(ContextCompat.getColor(context, R.color.background));
    previewSendButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    previewSendButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    stickerPreviewLayout.addView(previewSendButton,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT));
    previewSendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onStickerSelected(selectedSticker);
            dismiss();
        }
    });

    previewSendButtonShadow = new View(context);
    previewSendButtonShadow.setBackgroundResource(R.drawable.header_shadow_reverse);
    stickerPreviewLayout.addView(previewSendButtonShadow,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48));
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);

    updateFields();
    updateSendButton();
    adapter.notifyDataSetChanged();
}

From source file:ca.nehil.rter.streamingapp2.StreamingActivity.java

private void initLayout() {

    /* get size of screen */
    Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    screenWidth = display.getWidth();/* ww w . j av  a2s . co  m*/
    screenHeight = display.getHeight();
    FrameLayout.LayoutParams layoutParam = null;
    LayoutInflater myInflate = null;
    myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    FrameLayout topLayout = new FrameLayout(this);
    setContentView(topLayout);

    // openGLview
    mGLView = overlay.getGLView();

    /* add camera view */
    // int display_width_d = (int) (1.0 * bg_screen_width * screenWidth /
    // bg_width);
    // int display_height_d = (int) (1.0 * bg_screen_height * screenHeight /
    // bg_height);
    // int prev_rw, prev_rh;
    // if (1.0 * display_width_d / display_height_d > 1.0 * live_width /
    // live_height) {
    // prev_rh = display_height_d;
    // prev_rw = (int) (1.0 * display_height_d * live_width / live_height);
    // } else {
    // prev_rw = display_width_d;
    // prev_rh = (int) (1.0 * display_width_d * live_height / live_width);
    // }
    // layoutParam = new RelativeLayout.LayoutParams(prev_rw, prev_rh);
    // layoutParam.topMargin = (int) (1.0 * bg_screen_by * screenHeight /
    // bg_height);
    // layoutParam.leftMargin = (int) (1.0 * bg_screen_bx * screenWidth /
    // bg_width);

    int display_width_d = (int) (1.0 * screenWidth);
    int display_height_d = (int) (1.0 * screenHeight);
    int button_width = 0;
    int button_height = 0;
    int prev_rw, prev_rh;
    if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) {
        prev_rh = display_height_d;
        button_height = display_height_d;
        prev_rw = (int) (1.0 * display_height_d * live_width / live_height);
        button_width = display_width_d - prev_rw;

    } else {
        prev_rw = display_width_d;
        prev_rh = (int) (1.0 * display_width_d * live_height / live_width);
    }

    layoutParam = new FrameLayout.LayoutParams(prev_rw, prev_rh, Gravity.CENTER);
    //layoutParam = new FrameLayout.LayoutParams(prev_rw / 2, prev_rh / 2, Gravity.BOTTOM | Gravity.CENTER_VERTICAL);

    // layoutParam.topMargin = (int) (1.0 * bg_screen_by * screenHeight /
    // bg_height);
    // layoutParam.leftMargin = (int) (1.0 * bg_screen_bx * screenWidth /
    // bg_width);
    Log.d("LAYOUT",
            "display_width_d:" + display_width_d + ":: display_height_d:" + display_height_d + ":: prev_rw:"
                    + prev_rw + ":: prev_rh:" + prev_rh + ":: live_width:" + live_width + ":: live_height:"
                    + live_height + ":: button_width:" + button_width + ":: button_height:" + button_height);
    cameraDevice = openCamera();
    cameraView = new CameraView(this, cameraDevice);

    topLayout.addView(cameraView, layoutParam);
    topLayout.addView(mGLView, layoutParam);

    FrameLayout preViewLayout = (FrameLayout) myInflate.inflate(R.layout.activity_streaming, null);
    layoutParam = new FrameLayout.LayoutParams(screenWidth, screenHeight);
    topLayout.addView(preViewLayout, layoutParam);
    Log.i(LOG_TAG, "cameara preview start: OK");

    final Button recorderButton = (Button) findViewById(R.id.recorder_control);
    recorderButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (!recording) {
                Log.d(TAG, "attemptHandshaking");
                attemptHandshake();
                Log.w(LOG_TAG, "Start Button Pushed");
                recorderButton.setText("Stop");
            } else {
                stopRecording();
                Log.w(LOG_TAG, "Stop Button Pushed");
                recorderButton.setText("Start");
            }
        }
    });

}

From source file:com.github.michalbednarski.intentslab.AppComponentsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FragmentActivity activity = getActivity();
    FrameLayout frameLayout = new FrameLayout(activity);
    FrameLayout.LayoutParams stretch = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT);
    FrameLayout.LayoutParams center = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER);

    final ExpandableListView expandableListView = new ExpandableListView(activity);
    expandableListView.setAdapter(this);
    expandableListView.setOnChildClickListener(this);
    expandableListView.setLayoutParams(stretch);
    frameLayout.addView(expandableListView);

    final TextView emptyView = new TextView(activity);
    emptyView.setText(activity.getString(R.string.no_components));
    emptyView.setLayoutParams(center);/*ww  w . java 2 s .  com*/
    frameLayout.addView(emptyView);

    expandableListView.setEmptyView(emptyView);

    return frameLayout;
}