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, int index) 

Source Link

Document

Adds a child view.

Usage

From source file:com.rbware.github.androidcouchpotato.app.GuidedStepSupportFragment.java

/**
 * {@inheritDoc}//from w w  w. ja  v a  2 s .  c o m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG)
        Log.v(TAG, "onCreateView");

    resolveTheme();
    inflater = getThemeInflater(inflater);

    GuidedStepRootLayout root = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment,
            container, false);

    root.setFocusOutStart(isFocusOutStartAllowed());
    root.setFocusOutEnd(isFocusOutEndAllowed());

    ViewGroup guidanceContainer = (ViewGroup) root.findViewById(R.id.content_fragment);
    ViewGroup actionContainer = (ViewGroup) root.findViewById(R.id.action_fragment);

    Guidance guidance = onCreateGuidance(savedInstanceState);
    View guidanceView = mGuidanceStylist.onCreateView(inflater, guidanceContainer, guidance);
    guidanceContainer.addView(guidanceView);

    View actionsView = mActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(actionsView);

    View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer);
    actionContainer.addView(buttonActionsView);

    GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() {

        @Override
        public void onImeOpen() {
            runImeAnimations(true);
        }

        @Override
        public void onImeClose() {
            runImeAnimations(false);
        }

        @Override
        public long onGuidedActionEditedAndProceed(GuidedAction action) {
            return GuidedStepSupportFragment.this.onGuidedActionEditedAndProceed(action);
        }

        @Override
        public void onGuidedActionEditCanceled(GuidedAction action) {
            GuidedStepSupportFragment.this.onGuidedActionEditCanceled(action);
        }
    };

    mAdapter = new GuidedActionAdapter(mActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepSupportFragment.this.onGuidedActionClicked(action);
            if (isSubActionsExpanded()) {
                collapseSubActions();
            } else if (action.hasSubActions()) {
                expandSubActions(action);
            }
        }
    }, this, mActionsStylist, false);
    mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            GuidedStepSupportFragment.this.onGuidedActionClicked(action);
        }
    }, this, mButtonActionsStylist, false);
    mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() {
        @Override
        public void onGuidedActionClicked(GuidedAction action) {
            if (mActionsStylist.isInExpandTransition()) {
                return;
            }
            if (GuidedStepSupportFragment.this.onSubGuidedActionClicked(action)) {
                collapseSubActions();
            }
        }
    }, this, mActionsStylist, true);
    mAdapterGroup = new GuidedActionAdapterGroup();
    mAdapterGroup.addAdpter(mAdapter, mButtonAdapter);
    mAdapterGroup.addAdpter(mSubAdapter, null);
    mAdapterGroup.setEditListener(editListener);
    mActionsStylist.setEditListener(editListener);

    mActionsStylist.getActionsGridView().setAdapter(mAdapter);
    if (mActionsStylist.getSubActionsGridView() != null) {
        mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter);
    }
    mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter);
    if (mButtonActions.size() == 0) {
        // when there is no button actions, we don't need show the second panel, but keep
        // the width zero to run ChangeBounds transition.
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams();
        lp.weight = 0;
        buttonActionsView.setLayoutParams(lp);
    } else {
        // when there are two actions panel, we need adjust the weight of action to
        // guidedActionContentWidthWeightTwoPanels.
        Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity();
        TypedValue typedValue = new TypedValue();
        if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) {
            View actionsRoot = root.findViewById(R.id.action_fragment_root);
            float weight = typedValue.getFloat();
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams();
            lp.weight = weight;
            actionsRoot.setLayoutParams(lp);
        }
    }

    int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex
            : getFirstCheckedAction();
    setSelectedActionPosition(pos);

    setSelectedButtonActionPosition(0);

    // Add the background view.
    View backgroundView = onCreateBackgroundView(inflater, root, savedInstanceState);
    if (backgroundView != null) {
        FrameLayout backgroundViewRoot = (FrameLayout) root.findViewById(R.id.guidedstep_background_view_root);
        backgroundViewRoot.addView(backgroundView, 0);
    }
    return root;
}

From source file:org.solovyev.android.messenger.BaseListFragment.java

@Nonnull
private View createListView() {
    final Context context = getThemeContext();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout progressContainer = new LinearLayout(context);
    progressContainer.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    progressContainer.setOrientation(VERTICAL);
    progressContainer.setVisibility(GONE);
    progressContainer.setGravity(CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    progressContainer.addView(progress, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT));

    root.addView(progressContainer, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    // ------------------------------------------------------------------

    final FrameLayout listViewContainer = new FrameLayout(context);
    listViewContainer.setId(INTERNAL_LIST_CONTAINER_ID);

    final TextView emptyListCaption = new TextView(context);
    emptyListCaption.setId(INTERNAL_EMPTY_ID);
    emptyListCaption.setGravity(CENTER);
    listViewContainer.addView(emptyListCaption, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    final ListViewAwareOnRefreshListener topRefreshListener = getTopPullRefreshListener();
    final ListViewAwareOnRefreshListener bottomRefreshListener = getBottomPullRefreshListener();

    final View listView;

    if (topRefreshListener == null && bottomRefreshListener == null) {
        pullToRefreshMode = null;//from www . ja  v  a  2  s .  co m
        listView = createListView(context);
    } else {
        listView = createPullToRefreshListView(context, topRefreshListener, bottomRefreshListener);
    }

    listViewContainer.addView(listView, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    root.addView(listViewContainer, new LayoutParams(MATCH_PARENT, MATCH_PARENT));

    // ------------------------------------------------------------------

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

    return root;
}

From source file:com.gitstudy.rili.liarbry.CalendarView.java

/**
 * ?/*from   ww w .j a v  a  2s. co  m*/
 *
 * @param cls WeekBar.class
 */
public final void setWeekBar(Class<?> cls) {
    if (cls == null) {
        return;
    }
    if (mDelegate.getWeekBarClass().equals(cls)) {
        return;
    }
    mDelegate.setWeekBarClass(cls);
    FrameLayout frameContent = (FrameLayout) findViewById(R.id.frameContent);
    frameContent.removeView(mWeekBar);

    try {
        Constructor constructor = cls.getConstructor(Context.class);
        mWeekBar = (WeekBar) constructor.newInstance(getContext());
    } catch (Exception e) {
        e.printStackTrace();
    }
    frameContent.addView(mWeekBar, 2);
    mWeekBar.setup(mDelegate);
    mWeekBar.onWeekStartChange(mDelegate.getWeekStart());
    this.mMonthPager.mWeekBar = mWeekBar;
    mWeekBar.onDateSelected(mDelegate.mSelectedCalendar, mDelegate.getWeekStart(), false);
}

From source file:com.nadmm.airports.ActivityBase.java

public View createContentView(View view) {
    FrameLayout root = new FrameLayout(this);
    int white = ContextCompat.getColor(this, android.R.color.white);
    root.setBackgroundColor(white);/* w  w w .ja v  a2  s  . c  om*/
    root.setDrawingCacheBackgroundColor(white);
    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    LinearLayout pframe = new LinearLayout(this);
    pframe.setId(R.id.INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(this, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    FrameLayout lframe = new FrameLayout(this);
    lframe.setId(R.id.INTERNAL_FRAGMENT_CONTAINER_ID);
    lframe.setVisibility(View.GONE);

    lframe.addView(view, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:com.gitstudy.rili.liarbry.CalendarView.java

/**
 * ?//w ww  .  j a  va2  s .  c o  m
 *
 * @param context context
 */
private void init(Context context) {
    LayoutInflater.from(context).inflate(R.layout.cv_layout_calendar_view, this, true);
    FrameLayout frameContent = (FrameLayout) findViewById(R.id.frameContent);
    this.mWeekPager = (WeekViewPager) findViewById(R.id.vp_week);
    this.mWeekPager.setup(mDelegate);

    try {
        Constructor constructor = mDelegate.getWeekBarClass().getConstructor(Context.class);
        mWeekBar = (WeekBar) constructor.newInstance(getContext());
    } catch (Exception e) {
        e.printStackTrace();
    }

    frameContent.addView(mWeekBar, 2);
    mWeekBar.setup(mDelegate);
    mWeekBar.onWeekStartChange(mDelegate.getWeekStart());

    this.mWeekLine = findViewById(R.id.line);
    this.mWeekLine.setBackgroundColor(mDelegate.getWeekLineBackground());
    LayoutParams lineParams = (LayoutParams) this.mWeekLine.getLayoutParams();
    lineParams.setMargins(mDelegate.getWeekLineMargin(), mDelegate.getWeekBarHeight(),
            mDelegate.getWeekLineMargin(), 0);
    this.mWeekLine.setLayoutParams(lineParams);

    this.mMonthPager = (MonthViewPager) findViewById(R.id.vp_month);
    this.mMonthPager.mWeekPager = mWeekPager;
    this.mMonthPager.mWeekBar = mWeekBar;
    LayoutParams params = (LayoutParams) this.mMonthPager.getLayoutParams();
    params.setMargins(0, mDelegate.getWeekBarHeight() + CalendarUtil.dipToPx(context, 1), 0, 0);
    mWeekPager.setLayoutParams(params);

    mSelectLayout = (YearViewSelectLayout) findViewById(R.id.selectLayout);
    mSelectLayout.setBackgroundColor(mDelegate.getYearViewBackground());
    mSelectLayout.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            if (mWeekPager.getVisibility() == VISIBLE) {
                return;
            }
            if (mDelegate.mYearChangeListener != null) {
                mDelegate.mYearChangeListener.onYearChange(position + mDelegate.getMinYear());
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    mDelegate.mInnerListener = new OnInnerDateSelectedListener() {
        /**
         * 
         * @param calendar calendar
         * @param isClick  ?
         */
        @Override
        public void onMonthDateSelected(Calendar calendar, boolean isClick) {

            if (calendar.getYear() == mDelegate.getCurrentDay().getYear()
                    && calendar.getMonth() == mDelegate.getCurrentDay().getMonth()
                    && mMonthPager.getCurrentItem() != mDelegate.mCurrentMonthViewItem) {
                return;
            }
            mDelegate.mIndexCalendar = calendar;
            if (mDelegate.getSelectMode() == CalendarViewDelegate.SELECT_MODE_DEFAULT || isClick) {
                mDelegate.mSelectedCalendar = calendar;
            }
            mWeekPager.updateSelected(mDelegate.mIndexCalendar, false);
            mMonthPager.updateSelected();
            if (mWeekBar != null
                    && (mDelegate.getSelectMode() == CalendarViewDelegate.SELECT_MODE_DEFAULT || isClick)) {
                mWeekBar.onDateSelected(calendar, mDelegate.getWeekStart(), isClick);
            }
        }

        /**
         * 
         * @param calendar calendar
         * @param isClick ?
         */
        @Override
        public void onWeekDateSelected(Calendar calendar, boolean isClick) {
            mDelegate.mIndexCalendar = calendar;
            if (mDelegate.getSelectMode() == CalendarViewDelegate.SELECT_MODE_DEFAULT || isClick
                    || mDelegate.mIndexCalendar.equals(mDelegate.mSelectedCalendar)) {
                mDelegate.mSelectedCalendar = calendar;
            }
            int y = calendar.getYear() - mDelegate.getMinYear();
            int position = 12 * y + mDelegate.mIndexCalendar.getMonth() - mDelegate.getMinYearMonth();
            mWeekPager.updateSingleSelect();
            mMonthPager.setCurrentItem(position, false);
            mMonthPager.updateSelected();
            if (mWeekBar != null && (mDelegate.getSelectMode() == CalendarViewDelegate.SELECT_MODE_DEFAULT
                    || isClick || mDelegate.mIndexCalendar.equals(mDelegate.mSelectedCalendar))) {
                mWeekBar.onDateSelected(calendar, mDelegate.getWeekStart(), isClick);
            }
        }
    };

    if (isInRange(mDelegate.getCurrentDay())) {
        mDelegate.mSelectedCalendar = mDelegate.createCurrentDate();
    } else {
        mDelegate.mSelectedCalendar = mDelegate.getMinRangeCalendar();
    }

    mDelegate.mIndexCalendar = mDelegate.mSelectedCalendar;

    mWeekBar.onDateSelected(mDelegate.mSelectedCalendar, mDelegate.getWeekStart(), false);

    mMonthPager.setup(mDelegate);
    mMonthPager.setCurrentItem(mDelegate.mCurrentMonthViewItem);
    mSelectLayout.setOnMonthSelectedListener(new YearRecyclerView.OnMonthSelectedListener() {
        @Override
        public void onMonthSelected(int year, int month) {
            int position = 12 * (year - mDelegate.getMinYear()) + month - mDelegate.getMinYearMonth();
            mDelegate.isShowYearSelectedLayout = false;
            closeSelectLayout(position);
        }
    });
    mSelectLayout.setup(mDelegate);
    mWeekPager.updateSelected(mDelegate.createCurrentDate(), false);
}

From source file:org.vshgap.ui.Components.EmojiView.java

public EmojiView(boolean needStickers, Context context) {
    super(context);
    SharedPreferences themePrefs = ApplicationLoader.applicationContext
            .getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
    int bgColor = themePrefs.getInt("chatEmojiViewBGColor", 0xfff5f6f7);
    int tabColor = themePrefs.getInt("chatEmojiViewTabColor",
            AndroidUtilities.getIntDarkerColor("themeColor", -0x15));
    int lineColor = bgColor == 0xfff5f6f7 ? 0xffe2e5e7 : AndroidUtilities.setDarkColor(bgColor, 0x10);
    setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < Emoji.data.length; i++) {
        GridView gridView = new GridView(context);
        if (AndroidUtilities.isTablet()) {
            gridView.setColumnWidth(AndroidUtilities.dp(60));
        } else {//from www .j a va  2  s  .c  o m
            gridView.setColumnWidth(AndroidUtilities.dp(45));
        }
        gridView.setNumColumns(-1);
        views.add(gridView);

        EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]);
        gridView.setAdapter(emojiGridAdapter);
        //AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7);
        AndroidUtilities.setListViewEdgeEffectColor(gridView, bgColor);
        adapters.add(emojiGridAdapter);
    }

    if (needStickers) {
        GridView gridView = new GridView(context);
        gridView.setColumnWidth(AndroidUtilities.dp(72));
        gridView.setNumColumns(-1);
        gridView.setPadding(0, AndroidUtilities.dp(4), 0, 0);
        gridView.setClipToPadding(false);
        views.add(gridView);
        stickersGridAdapter = new StickersGridAdapter(context);
        gridView.setAdapter(stickersGridAdapter);
        //AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7);
        AndroidUtilities.setListViewEdgeEffectColor(gridView, bgColor);
    }

    //setBackgroundColor(0xfff5f6f7);
    setBackgroundColor(bgColor);

    pager = new ViewPager(context);
    pager.setAdapter(new EmojiPagesAdapter());

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    //linearLayout.setBackgroundColor(0xfff5f6f7);
    linearLayout.setBackgroundColor(bgColor);
    addView(linearLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, AndroidUtilities.dp(48)));

    PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(context);
    tabs.setViewPager(pager);
    tabs.setShouldExpand(true);
    tabs.setIndicatorHeight(AndroidUtilities.dp(2));
    tabs.setUnderlineHeight(AndroidUtilities.dp(1));
    //tabs.setIndicatorColor(0xff2b96e2);
    tabs.setIndicatorColor(tabColor);
    //tabs.setUnderlineColor(0xffe2e5e7);
    tabs.setUnderlineColor(lineColor);
    linearLayout.addView(tabs, new LinearLayout.LayoutParams(0, AndroidUtilities.dp(48), 1.0f));

    FrameLayout frameLayout = new FrameLayout(context);
    linearLayout.addView(frameLayout,
            new LinearLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48)));

    backspaceButton = new ImageView(context) {
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                backspacePressed = true;
                backspaceOnce = false;
                postBackspaceRunnable(350);
            } else if (event.getAction() == MotionEvent.ACTION_CANCEL
                    || event.getAction() == MotionEvent.ACTION_UP) {
                backspacePressed = false;
                if (!backspaceOnce) {
                    if (EmojiView.this.listener != null && EmojiView.this.listener.onBackspace()) {
                        backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
                    }
                }
            }
            super.onTouchEvent(event);
            return true;
        }
    };
    backspaceButton.setImageResource(R.drawable.ic_smiles_backspace);
    backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace);
    backspaceButton.setScaleType(ImageView.ScaleType.CENTER);
    frameLayout.addView(backspaceButton,
            new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48)));

    View view = new View(context);
    //view.setBackgroundColor(0xffe2e5e7);
    view.setBackgroundColor(lineColor);
    frameLayout.addView(view, new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(1),
            Gravity.LEFT | Gravity.BOTTOM));

    recentsWrap = new FrameLayout(context);
    recentsWrap.addView(views.get(0));

    TextView textView = new TextView(context);
    textView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
    textView.setTextSize(18);
    textView.setTextColor(0xff888888);
    textView.setGravity(Gravity.CENTER);
    recentsWrap.addView(textView);
    views.get(0).setEmptyView(textView);

    addView(pager);

    loadRecents();

    if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
        pager.setCurrentItem(1);
    }

}

From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java

@Override
public void swapToCustomView(View customView) {
    FrameLayout shadow = (FrameLayout) findViewById(R.id.shadow_content);
    View frags = findViewById(R.id.main_content);
    View wkt = findViewById(R.id.webkit_view);
    shadow.removeAllViews();/*from  www  .  ja v a  2 s.c  o  m*/
    shadow.addView(customView, COVER_SCREEN_GRAVITY_CENTER);
    frags.setVisibility(View.GONE);
    wkt.setVisibility(View.GONE);
    shadow.setVisibility(View.VISIBLE);
    currentFragment = ScreenList.CUSTOM_VIEW;
}

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/*  w w w.j  a  v a2s  .c om*/
        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:com.waz.zclient.ui.cursor.CursorToolbar.java

private void createItems() {
    LayoutInflater inflater = LayoutInflater.from(getContext());

    int diameter = getResources().getDimensionPixelSize(R.dimen.cursor__menu_button__diameter);
    int rightMargin;

    /*/*  w w  w.  j a  v  a 2 s . co  m*/
    As long as 4 mainItems are shown in the toolbar, they are spread out equally in phone
     */
    rightMargin = CursorUtils.getMarginBetweenCursorButtons(getContext());

    CursorIconButton cursorIconButton;

    for (int i = 0; i < cursorItems.size(); i++) {
        final CursorMenuItem item = cursorItems.get(i);
        final FrameLayout buttonContainer = new FrameLayout(getContext());
        buttonContainer.setId(item.resId);

        cursorIconButton = (CursorIconButton) inflater.inflate(R.layout.cursor__item, this, false);
        cursorIconButton.setText(item.glyphResId);
        cursorIconButton
                .setPressedBackgroundColor(ContextCompat.getColor(getContext(), R.color.light_graphite));

        switch (item) {
        case CAMERA:
            cursorIconButtonCamera = cursorIconButton;
            break;
        case AUDIO_MESSAGE:
            cursorIconButtonAudio = cursorIconButton;
            break;
        }

        if (item == CursorMenuItem.DUMMY) {
            cursorIconButton.initTextColor(ContextCompat.getColor(getContext(), R.color.transparent));
            cursorIconButton
                    .setPressedBackgroundColor(ContextCompat.getColor(getContext(), R.color.transparent));
            cursorIconButton.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.transparent));
        }

        buttonContainer.setTag(item);

        buttonContainer.setLongClickable(true);

        buttonContainer.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                CursorMenuItem item = (CursorMenuItem) view.getTag();
                touchedButtonContainer = buttonContainer;
                if (callback != null && item == CursorMenuItem.AUDIO_MESSAGE) {
                    callback.onMotionEvent(item, motionEvent);
                }
                detector.onTouchEvent(motionEvent);
                return false;
            }
        });

        FrameLayout.LayoutParams paramsButton = new FrameLayout.LayoutParams(diameter, diameter);
        paramsButton.gravity = Gravity.CENTER;
        buttonContainer.addView(cursorIconButton, paramsButton);

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(buttonWidth,
                ViewGroup.LayoutParams.MATCH_PARENT);
        if (i < cursorItems.size() - 1) {
            params.rightMargin = rightMargin;
        }
        addView(buttonContainer, params);
    }
}

From source file:org.godotengine.godot.AdMob.java

public void createBanner() {
    if (AdMobConfig == null) {
        return;/*w  w  w  .j  ava2s. c  o m*/
    }

    FrameLayout layout = ((Godot) activity).layout; // Getting Godots framelayout
    FrameLayout.LayoutParams AdParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);

    if (mAdView != null) {
        layout.removeView(mAdView);
    }

    if (AdMobConfig.optString("BannetGravity", "BOTTOM").equals("BOTTOM")) {
        AdParams.gravity = Gravity.BOTTOM;
    } else {
        AdParams.gravity = Gravity.TOP;
    }

    AdRequest.Builder adRequestB = new AdRequest.Builder();
    adRequestB.tagForChildDirectedTreatment(true);

    if (BuildConfig.DEBUG) {
        adRequestB.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
        adRequestB.addTestDevice(Utils.getDeviceId(activity));
    }

    AdRequest adRequest = adRequestB.build();

    String ad_unit_id = AdMobConfig.optString("BannerAdId", "");

    if (ad_unit_id.length() <= 0) {
        Utils.d("AdMob:Banner:UnitId:NotProvided");
        ad_unit_id = activity.getString(R.string.banner_ad_unit_id);
    }

    mAdView = new AdView(activity);
    mAdView.setBackgroundColor(Color.TRANSPARENT);
    mAdView.setAdUnitId(ad_unit_id);
    mAdView.setAdSize(AdSize.SMART_BANNER);

    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            Utils.d("AdMob:Banner:OnAdLoaded");
            Utils.callScriptFunc("AdMob_Banner", "loaded");
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            Utils.w("AdMob:Banner:onAdFailedToLoad:" + errorCode);
            Utils.callScriptFunc("AdMob_Banner", "load_failed");
        }
    });

    mAdView.setVisibility(View.INVISIBLE);
    mAdView.loadAd(adRequest);

    layout.addView(mAdView, AdParams);
}