Java Code Examples for android.widget.FrameLayout#LayoutParams

The following examples show how to use android.widget.FrameLayout#LayoutParams . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecyclerViewHeader.java    From Android-Application-ZJB with Apache License 2.0 7 votes vote down vote up
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 {
            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);
        }
    }
}
 
Example 2
Source File: TBSFileViewActivity.java    From AndroidDocumentViewer with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tbs_file_view_layout);
    rootViewParent = (FrameLayout) findViewById(R.id.fl_rootview);
    errorHandleLayout = (ViewGroup) findViewById(R.id.ll_error_handle);
    initErrorHandleLayout(errorHandleLayout);

    filePath = handleIntent();
    if (TextUtils.isEmpty(filePath) || !new File(filePath).isFile()) {
        Toast.makeText(this, getString(R.string.file_not_exist), Toast.LENGTH_SHORT).show();
        finish();
    }

    getSupportActionBar().setTitle(getString(R.string.view_file) + getFileName(filePath));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mTbsReaderView = new TbsReaderView(this, this);
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT
    );
    mTbsReaderView.setLayoutParams(layoutParams);
    rootViewParent.addView(mTbsReaderView);
    displayFile(filePath);
}
 
Example 3
Source File: VideoDivideActivity.java    From PLDroidShortVideo with Apache License 2.0 6 votes vote down vote up
private void addSelectorView() {
    mCurSelectorView = new FrameSelectorView(this);
    final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, mFrameListParent.getHeight());
    mCurSelectorView.setVisibility(View.INVISIBLE);
    mScrollViewParent.addView(mCurSelectorView, layoutParams);

    mCurSelectorView.post(new Runnable() {
        @Override
        public void run() {
            // put mCurSelectorView to the middle of the horizontal
            layoutParams.leftMargin = (mScrollViewParent.getWidth() - mCurSelectorView.getWidth()) / 2;
            mCurSelectorView.setLayoutParams(layoutParams);
            mCurSelectorView.setVisibility(View.VISIBLE);
        }
    });
}
 
Example 4
Source File: CommonLayoutParams.java    From tns-core-modules-widgets with Apache License 2.0 6 votes vote down vote up
public CommonLayoutParams(CommonLayoutParams source) {
    this((FrameLayout.LayoutParams) source);

    this.widthPercent = source.widthPercent;
    this.heightPercent = source.heightPercent;

    this.topMargin = source.topMargin;
    this.leftMargin = source.leftMargin;
    this.bottomMargin = source.bottomMargin;
    this.rightMargin = source.rightMargin;

    this.left = source.left;
    this.top = source.top;
    this.row = source.row;
    this.column = source.column;
    this.rowSpan = source.rowSpan;
    this.columnSpan = source.columnSpan;
    this.dock = source.dock;
}
 
Example 5
Source File: ViewLayoutUtils.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
public static MarginLayoutParams newLayoutParam(final ViewGroup placer, final int width,
        final int height) {
    if (placer instanceof FrameLayout) {
        return new FrameLayout.LayoutParams(width, height);
    } else if (placer instanceof RelativeLayout) {
        return new RelativeLayout.LayoutParams(width, height);
    } else if (placer == null) {
        throw new NullPointerException("placer is null");
    } else {
        throw new IllegalArgumentException("placer is neither FrameLayout nor RelativeLayout: "
                + placer.getClass().getName());
    }
}
 
Example 6
Source File: MizLib.java    From Mizuu with Apache License 2.0 5 votes vote down vote up
/**
 * Add a margin with a height of the ActionBar to the top of a given View contained in a FrameLayout
 * @param c
 * @param v
 */
public static void addActionBarMargin(Context c, View v) {
    int mActionBarHeight = 0;
    TypedValue tv = new TypedValue();
    if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
        mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics());
    else
        mActionBarHeight = 0; // No ActionBar style (pre-Honeycomb or ActionBar not in theme)

    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    params.setMargins(0, mActionBarHeight, 0, 0);
    v.setLayoutParams(params);
}
 
Example 7
Source File: LineView.java    From BalloonPerformer with Apache License 2.0 5 votes vote down vote up
private void addLine(int x, int y, int offsetX) {
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    mOriY = -mLineLength + y + ViewUtil.getStatusBarHeight(mContext);
    // 如果view没有被加入到某个父组件中,则加入WindowManager中
    if (this.getParent() == null) {
        mContainer.addView(this, lp);
        // ViewHelper.setTranslationY(this, mOriY);
        // ViewHelper.setTranslationX(this, x);
        updateByPos(x, y, offsetX);
    }
}
 
Example 8
Source File: VideoPlayerView.java    From TigerVideo with Apache License 2.0 5 votes vote down vote up
/**
 * 开始小窗口播放
 */
protected void onStartSmallWindowPlay() {

    mVideoControllerView.stopVideoProgressUpdate();
    setCurrentScreenState(ScreenState.SCREEN_STATE_SMALL_WINDOW);
    PlayerManager.getInstance().setTextureView(null);
    mVideoTextureViewContainer.removeAllViews();
    VideoPlayerView smallWindowView = new VideoPlayerView(getContext());
    smallWindowView.setId(R.id.vp_small_window_view_id);
    smallWindowView.mVideoControllerView.cloneState(mVideoControllerView);
    smallWindowView.mVideoHeaderView.setTitle(mVideoTitle);
    smallWindowView.mVideoUrl = mVideoUrl;
    smallWindowView.mViewHash = mViewHash;
    TextureView textureView = smallWindowView.createTextureView();
    smallWindowView.mVideoTextureViewContainer.addView(textureView);
    PlayerManager.getInstance().setTextureView(textureView);

    ViewGroup windowContent = (ViewGroup) (Utils.getActivity(getContext())).findViewById(Window.ID_ANDROID_CONTENT);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(mSmallWindowWidth, mSmallWindowHeight);
    lp.gravity = Gravity.RIGHT|Gravity.BOTTOM;
    windowContent.addView(smallWindowView, lp);

    /**
     * 先将小窗口播放视频的View添加到Window后再设置小窗口View的屏幕状态,
     * 否则会导致小窗口触发attach window时又立刻执行了toggleSmallWindow()从而又退出了小窗口播放
     *
     * 下面状态的设置必须在addView之后执行,否则会进入死循环
     */
    smallWindowView.mCurrentScreenState = getCurrentScreenState();
    smallWindowView.mCurrentState = mCurrentState;

    smallWindowView.onPlayStateChanged(mCurrentState);
}
 
Example 9
Source File: SnackbarUtils.java    From SweetTips with Apache License 2.0 5 votes vote down vote up
/**
 * 设置SweetSnackbar实例显示的位置
 * @param gravity
 */
public SnackbarUtils gravityFrameLayout(int gravity){
    if(getSnackbar()!=null){
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(getSnackbar().getView().getLayoutParams().width,getSnackbar().getView().getLayoutParams().height);
        params.gravity = gravity;
        getSnackbar().getView().setLayoutParams(params);
    }
    return this;
}
 
Example 10
Source File: BrowseErrorActivity.java    From TvAppRepo with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    ProgressBar progressBar = new ProgressBar(container.getContext());
    if (container instanceof FrameLayout) {
        FrameLayout.LayoutParams layoutParams =
                new FrameLayout.LayoutParams(SPINNER_WIDTH, SPINNER_HEIGHT, Gravity.CENTER);
        progressBar.setLayoutParams(layoutParams);
    }
    return progressBar;
}
 
Example 11
Source File: ModClearAllRecents.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@SuppressLint("RtlHardcoded")
private static void updateRamBarLayout() {
    if (mRamUsageBar == null || mRamBarGravity == 0) return;

    final Context context = mRamUsageBar.getContext();
    final Resources res = mRamUsageBar.getResources();
    final int orientation = res.getConfiguration().orientation;
    final boolean caOnTop = (mButtonGravity & Gravity.TOP) == Gravity.TOP;
    final boolean caOnLeft = (mButtonGravity & Gravity.LEFT) == Gravity.LEFT;
    final boolean rbOnTop = (mRamBarGravity == Gravity.TOP);
    final int marginTop = rbOnTop ? mMarginTopPx : 0;
    final int marginBottom = (!rbOnTop && (orientation == Configuration.ORIENTATION_PORTRAIT ||
            !Utils.isPhoneUI(context))) ? mMarginBottomPx : 0;
    final int marginLeft = orientation == Configuration.ORIENTATION_LANDSCAPE &&
            Utils.isPhoneUI(context) & mNavbarLeftHanded ? mMarginBottomPx : 0;
    final int marginRight = orientation == Configuration.ORIENTATION_LANDSCAPE &&
            Utils.isPhoneUI(context) & !mNavbarLeftHanded ? mMarginBottomPx : 0;

    FrameLayout.LayoutParams flp = (FrameLayout.LayoutParams) mRamUsageBar.getLayoutParams();
    flp.gravity = mRamBarGravity;
    flp.setMargins(mRamUsageBarHorizontalMargin + marginLeft,
            rbOnTop ? (mRamUsageBarVerticalMargin + marginTop) : 0,
            mRamUsageBarHorizontalMargin + marginRight,
            rbOnTop ? 0 : (mRamUsageBarVerticalMargin + marginBottom)
    );
    mRamUsageBar.setLayoutParams(flp);
    if (DEBUG) log("RAM bar layout updated");
}
 
Example 12
Source File: AppbarActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
private void createViews() {
    LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
    this.mWebView.setLayoutParams(layoutParams);
    this.mRootView = new LinearLayout(this);
    layoutParams.gravity = 17;
    this.mRootView.setLayoutParams(layoutParams);
    this.mRootView.setOrientation(1);
    this.mTitleBar = new TitleBar(this);
    this.mTitleBar.getBackBtn().setOnClickListener(this);
    this.mTitleBar.getSharBtn().setOnClickListener(this);
    this.mRootView.addView(this.mTitleBar);
    this.mRootView.addView(this.mWebView);
    setContentView(this.mRootView);
}
 
Example 13
Source File: CurtainViewController.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 为控件做一些属性设置
 */
protected void prepareSlidingLayout() {
    curtainLayoutParams = (FrameLayout.LayoutParams) curtainParent
            .getLayoutParams();
    ViewTreeObserver vto = curtainParent.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        @SuppressLint("NewApi")
        public void onGlobalLayout() {
            hideCurtainLayout();
            ViewTreeObserver obs = curtainParent.getViewTreeObserver();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                obs.removeOnGlobalLayoutListener(this);
            } else {
                obs.removeGlobalOnLayoutListener(this);
            }
        }

    });

    curtainParent.setOnTouchListener(new OnContentTouchListener());

    curtainParent.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK
                    && getSlidingStatus() == SlidingStatus.EXPANDED) {
                collapse();
                return true;
            } else {
                return false;
            }
        }
    });
}
 
Example 14
Source File: LayoutHelper.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public static FrameLayout.LayoutParams createFrame(int width, float height, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(getSize(width), getSize(height), gravity);
    layoutParams.setMargins(AndroidUtilities.dp(leftMargin), AndroidUtilities.dp(topMargin), AndroidUtilities.dp(rightMargin), AndroidUtilities.dp(bottomMargin));
    return layoutParams;
}
 
Example 15
Source File: PullToZoomScrollView.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent ev) {
    Log.d(TAG, "onTouchEvent --> action = " + (0xFF & ev.getAction()));
    if (isHeaderTop && isEnableZoom) {
        switch (0xFF & ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_OUTSIDE:
                if (!mScalingRunnable.isFinished()) {
                    mScalingRunnable.abortAnimation();
                }
                mLastMotionY = ev.getY();
                mActivePointerId = ev.getPointerId(0);
                mMaxScale = (mScreenHeight / mZoomHeight);
                mLastScale = (mZoomContainer.getBottom() / mZoomHeight);
                if (onScrollViewZoomListener != null) {
                    onScrollViewZoomListener.onStart();
                }
                break;
            case MotionEvent.ACTION_MOVE:
                Log.d(TAG, "mActivePointerId = " + mActivePointerId);
                int j = ev.findPointerIndex(this.mActivePointerId);
                if (j == -1) {
                    Log.e(TAG, "Invalid pointerId = " + mActivePointerId + " in onTouchEvent");
                } else {
                    if (mLastMotionY == -1.0F) {
                        mLastMotionY = ev.getY(j);
                    }
                    if (mZoomContainer.getBottom() >= mZoomHeight) {
                        FrameLayout.LayoutParams localLayoutParams = (FrameLayout.LayoutParams) mZoomContainer.getLayoutParams();
                        ViewGroup.LayoutParams headLayoutParams = mHeaderContainer.getLayoutParams();
                        float f = ((ev.getY(j) - mLastMotionY + mZoomContainer.getBottom()) / mZoomHeight - mLastScale) / 2.0F + mLastScale;
                        if ((mLastScale <= 1.0D) && (f < mLastScale)) {
                            localLayoutParams.height = mZoomHeight;
                            localLayoutParams.width = mZoomWidth;
                            localLayoutParams.gravity = Gravity.CENTER;
                            headLayoutParams.height = mZoomHeight;
                            mZoomContainer.setLayoutParams(localLayoutParams);
                            mHeaderContainer.setLayoutParams(headLayoutParams);
                            return super.onTouchEvent(ev);
                        }
                        mLastScale = Math.min(Math.max(f, 1.0F), mMaxScale);
                        localLayoutParams.height = ((int) (mZoomHeight * mLastScale));
                        localLayoutParams.width = ((int) (mZoomWidth * mLastScale));
                        localLayoutParams.gravity = Gravity.CENTER;
                        headLayoutParams.height = ((int) (mZoomHeight * mLastScale));
                        if (localLayoutParams.height < mScreenHeight) {
                            mZoomContainer.setLayoutParams(localLayoutParams);
                            mHeaderContainer.setLayoutParams(headLayoutParams);
                        }
                        mLastMotionY = ev.getY(j);
                        return true;
                    }
                    this.mLastMotionY = ev.getY(j);
                }
                break;
            case MotionEvent.ACTION_UP:
                reset();
                endScaling();
                if (onScrollViewZoomListener != null) {
                    onScrollViewZoomListener.onFinish();
                }
                break;
            case MotionEvent.ACTION_CANCEL:
                int i = ev.getActionIndex();
                mLastMotionY = ev.getY(i);
                mActivePointerId = ev.getPointerId(i);
                break;
            case MotionEvent.ACTION_POINTER_DOWN:
                onSecondaryPointerUp(ev);
                mLastMotionY = ev.getY(ev.findPointerIndex(mActivePointerId));
                break;
        }
    }
    return super.onTouchEvent(ev);
}
 
Example 16
Source File: AppBarScrollParent.java    From cathode with Apache License 2.0 4 votes vote down vote up
@Override public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attrs) {
  return new LayoutParams(getContext(), attrs);
}
 
Example 17
Source File: LauncherActivity.java    From paper-launcher with MIT License 4 votes vote down vote up
@Override
public void onPanelSlide(View panel, float slideOffset) {
    mDockViewPagerAdapter.getHomeScreenDockFragment().stopEditAnimation();

    SystemBarUtil.setStatusBarColor(this, (Integer) new ArgbEvaluator().evaluate(slideOffset,
            Color.TRANSPARENT, ContextCompat.getColor(this, R.color.colorStatusBar)));

    if (slideOffset >= 0.6) {
        SystemBarUtil.enableLightStatusBar(this);
    } else {
        SystemBarUtil.clearLightStatusBar(this);
    }

    boolean isShowingHomeScreenDock = mDockViewPager.getCurrentItem() == 0;
    if (isShowingHomeScreenDock) {
        mDockViewPager.scrollTo((int) (mDockViewPager.getWidth() * slideOffset), 0);
    }

    FrameLayout.LayoutParams searchBarCardViewLayoutParams = (FrameLayout.LayoutParams) mSearchBarCardView.getLayoutParams();

    searchBarCardViewLayoutParams.topMargin = (int) (DpPxUtil.dpToPx(this, 32)
            - DpPxUtil.dpToPx(this, 8) * slideOffset);
    searchBarCardViewLayoutParams.leftMargin = (int) (DpPxUtil.dpToPx(this, 8)
            - DpPxUtil.dpToPx(this, 8) * slideOffset);
    searchBarCardViewLayoutParams.rightMargin = (int) (DpPxUtil.dpToPx(this, 8)
            - DpPxUtil.dpToPx(this, 8) * slideOffset);
    searchBarCardViewLayoutParams.height = (int) (DpPxUtil.dpToPx(this, 48)
            + DpPxUtil.dpToPx(this, 8) * slideOffset);

    mSearchBarCardView.setLayoutParams(searchBarCardViewLayoutParams);

    float searchBarCardViewElevation = DpPxUtil.dpToPx(this, 4)
            - DpPxUtil.dpToPx(this, 4) * slideOffset;
    mSearchBarCardView.setCardElevation(searchBarCardViewElevation);

    float searchBarCardViewRadius = DpPxUtil.dpToPx(this, 2)
            - DpPxUtil.dpToPx(this, 2) * slideOffset;
    // CardView bug, if radius equals to 0.xxx, the alpha will be changed
    mSearchBarCardView.setRadius(
            String.valueOf(searchBarCardViewRadius).charAt(0) == '0'
                    ? 0
                    : searchBarCardViewRadius);

    mGoogleArrowImageView.animate()
            .setDuration(0)
            .rotation(-90 * slideOffset)
            .translationX(DpPxUtil.dpToPx(this, 12) * slideOffset)
            .start();

    mGoogleIconImageView.animate()
            .setDuration(0)
            .scaleX(1 - slideOffset)
            .scaleY(1 - slideOffset)
            .start();

    mSearchAppsTextView.animate()
            .setDuration(0)
            .alpha(slideOffset)
            .start();

    mWallpaperOverlay.animate()
            .setDuration(0)
            .alpha(slideOffset)
            .start();

    mSearchAppsWrapperView.animate()
            .setDuration(0)
            .translationX(-DpPxUtil.dpToPx(this, 26) * slideOffset)
            .start();

    mSearchBarPillDividerView.animate()
            .setDuration(0)
            .translationX(-DpPxUtil.dpToPx(this, 16) * slideOffset)
            .start();

    mGoogleMicImageView.setColorFilter((Integer) new ArgbEvaluator().evaluate(slideOffset, Color.TRANSPARENT,
            ContextCompat.getColor(this, R.color.colorMicOnAppDrawer)));
}
 
Example 18
Source File: DotWidget.java    From star-zone-android with Apache License 2.0 4 votes vote down vote up
private void initDotParams(int dotSize) {
    int dotHeightAndWidth = dip2Pixels(dotSize);

    FrameLayout.LayoutParams dotParams = new FrameLayout.LayoutParams(dotHeightAndWidth, dotHeightAndWidth);

    switch (gravity) {
        case GRAVITY_TOP_LEFT:
            dotParams.gravity = Gravity.LEFT | Gravity.TOP;
            break;
        case GRAVITY_TOP_RIGHT:
            dotParams.gravity = Gravity.RIGHT | Gravity.TOP;
            break;
        case GRAVITY_BOTTOM_LEFT:
            dotParams.gravity = Gravity.LEFT | Gravity.BOTTOM;
            break;
        case GRAVITY_BOTTOM_RIGHT:
            dotParams.gravity = Gravity.RIGHT | Gravity.BOTTOM;
            break;
        case GRAVITY_CENTER:
            dotParams.gravity = Gravity.CENTER;
            break;
        case GRAVITY_CENTER_VERTICAL:
            dotParams.gravity = Gravity.CENTER_VERTICAL;
            break;
        case GRAVITY_CENTER_HORIZONTAL:
            dotParams.gravity = Gravity.CENTER_HORIZONTAL;
            break;
        case GRAVITY_LEF_CENTER:
            dotParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
            break;
        case GRAVITY_RIGHT_CENTER:
            dotParams.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
            break;
        default:
            break;
    }

    dotParams.setMargins(marginRect.left, marginRect.top, marginRect.right, marginRect.bottom);

    this.setLayoutParams(dotParams);
}
 
Example 19
Source File: TransparentActivity.java    From UETool with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        finish();
        return;
    }
    Util.setStatusBarColor(getWindow(), Color.TRANSPARENT);
    Util.enableFullscreen(getWindow());
    setContentView(R.layout.uet_activity_transparent);

    vContainer = findViewById(R.id.container);

    final BoardTextView board = new BoardTextView(this);

    type = getIntent().getIntExtra(EXTRA_TYPE, TYPE_UNKNOWN);

    switch (type) {
        case TYPE_EDIT_ATTR:
            EditAttrLayout editAttrLayout = new EditAttrLayout(this);
            editAttrLayout.setOnDragListener(new EditAttrLayout.OnDragListener() {
                @Override
                public void showOffset(String offsetContent) {
                    board.updateInfo(offsetContent);
                }
            });
            vContainer.addView(editAttrLayout);
            break;
        case TYPE_RELATIVE_POSITION:
            vContainer.addView(new RelativePositionLayout(this));
            break;
        case TYPE_SHOW_GRIDDING:
            vContainer.addView(new GriddingLayout(this));
            board.updateInfo("LINE_INTERVAL: " + DimenUtil.px2dip(GriddingLayout.LINE_INTERVAL, true));
            break;
        default:
            Toast.makeText(this, getString(R.string.uet_coming_soon), Toast.LENGTH_SHORT).show();
            finish();
            break;
    }

    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    params.gravity = BOTTOM;
    vContainer.addView(board, params);
}
 
Example 20
Source File: AppMsg.java    From fanfouapp-opensource with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs and sets the layout parameters to have some gravity.
 * 
 * @param gravity
 *            the gravity of the Crouton
 * @return <code>this</code>, for chaining.
 * @see android.view.Gravity
 */
public AppMsg setLayoutGravity(final int gravity) {
    this.mLayoutParams = new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, gravity);
    return this;
}