Java Code Examples for android.widget.RelativeLayout#setLayoutParams()

The following examples show how to use android.widget.RelativeLayout#setLayoutParams() . 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: TreeNodeWrapperView.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void init() {
    setOrientation(LinearLayout.VERTICAL);

    nodeContainer = new RelativeLayout(getContext());
    nodeContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeContainer.setId(R.id.node_header);

    ContextThemeWrapper newContext = new ContextThemeWrapper(getContext(), containerStyle);
    nodeItemsContainer = new LinearLayout(newContext, null, containerStyle);
    nodeItemsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeItemsContainer.setId(R.id.node_items);
    nodeItemsContainer.setOrientation(LinearLayout.VERTICAL);
    nodeItemsContainer.setVisibility(View.GONE);

    addView(nodeContainer);
    addView(nodeItemsContainer);
}
 
Example 2
Source File: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
Example 3
Source File: TreeNodeWrapperView.java    From imsdk-android with MIT License 6 votes vote down vote up
private void init() {
    setOrientation(LinearLayout.VERTICAL);

    nodeContainer = new RelativeLayout(getContext());
    nodeContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeContainer.setId(R.id.node_header);

    ContextThemeWrapper newContext = new ContextThemeWrapper(getContext(), containerStyle);
    nodeItemsContainer = new LinearLayout(newContext, null, containerStyle);
    nodeItemsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeItemsContainer.setId(R.id.node_items);
    nodeItemsContainer.setOrientation(LinearLayout.VERTICAL);
    nodeItemsContainer.setVisibility(View.GONE);

    addView(nodeContainer);
    addView(nodeItemsContainer);
}
 
Example 4
Source File: AbsFullDialogFragment.java    From ZhihuDailyFluxRRD with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // the content
    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    // creating the fullscreen dialog
    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return dialog;
}
 
Example 5
Source File: TreeNodeWrapperView.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
private void init() {
    setOrientation(LinearLayout.VERTICAL);

    nodeContainer = new RelativeLayout(getContext());
    nodeContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeContainer.setId(R.id.node_header);

    ContextThemeWrapper newContext = new ContextThemeWrapper(getContext(), containerStyle);
    nodeItemsContainer = new LinearLayout(newContext, null, containerStyle);
    nodeItemsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    nodeItemsContainer.setId(R.id.node_items);
    nodeItemsContainer.setOrientation(LinearLayout.VERTICAL);
    nodeItemsContainer.setVisibility(View.GONE);

    addView(nodeContainer);
    addView(nodeItemsContainer);
}
 
Example 6
Source File: AudioVideoPlayUseVideoViewActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
private void initLayout() {
    DisplayMetrics dm = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(dm);
    RelativeLayout layout = (RelativeLayout) this.findViewById(R.id.videoview_fixed_layout);
    int width = dm.widthPixels;
    int height = width * 360 / 640;

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height);
    layout.setLayoutParams(layoutParams);
}
 
Example 7
Source File: ChannelTabPageIndicator.java    From letv with Apache License 2.0 5 votes vote down vote up
protected void addTab(int index, CharSequence text, int iconResId) {
    TabView tabView = new TabView(this, getContext(), text);
    tabView.setIndex(index);
    tabView.setFocusable(true);
    tabView.setOnClickListener(this.mTabClickListener);
    if (iconResId != 0) {
        tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
    }
    int width = this.mMeanWidth == -1 ? getTabWidth(text) : this.mMeanWidth;
    if (this.mMeanWidth != -1) {
        tabView.setSize(this.mMeanWidth, UIsUtils.dipToPx(38.0f));
    } else {
        tabView.setSize(width, UIsUtils.dipToPx(38.0f));
    }
    RelativeLayout relativeLayout = new RelativeLayout(this.mContext);
    relativeLayout.setGravity(17);
    relativeLayout.setLayoutParams(new LayoutParams(-2, UIsUtils.dipToPx(38.0f)));
    LayoutParams params = new LayoutParams(-2, UIsUtils.dipToPx(38.0f));
    params.setMargins(TAB_MARGIN, 0, TAB_MARGIN, 0);
    tabView.setLayoutParams(params);
    relativeLayout.addView(tabView);
    if (this.mIsHome) {
        ThemeDataManager.getInstance(this.mContext).setContentTheme(tabView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR);
    }
    ImageView imageView = new ImageView(this.mContext);
    LayoutParams imageViewParams = new LayoutParams(width, UIsUtils.dipToPx(2.0f));
    imageViewParams.setMargins(TAB_MARGIN, UIsUtils.dipToPx(36.0f), TAB_MARGIN, 0);
    imageView.setLayoutParams(imageViewParams);
    relativeLayout.addView(imageView);
    imageView.setBackgroundDrawable(getResources().getDrawable(2130838177));
    if (this.mIsHome) {
        ThemeDataManager.getInstance(this.mContext).setShapeSelectorViewTheme(imageView, ThemeDataManager.NAME_TOP_NAVIGATION_COLOR, 2, true);
    }
    this.mTabLayout.addView(relativeLayout);
}
 
Example 8
Source File: PictureUploadPopUpFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {

    RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    return dialog;
}
 
Example 9
Source File: FFmpegPreviewActivity.java    From VideoRecorder with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_ffmpeg_preview);

	cancelBtn = (Button) findViewById(R.id.play_cancel);
	cancelBtn.setOnClickListener(this);
	
	DisplayMetrics displaymetrics = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
	surfaceView = (TextureView) findViewById(R.id.preview_video);
	
	RelativeLayout previewVideoParent = (RelativeLayout)findViewById(R.id.preview_video_parent);
	LayoutParams layoutParams = (LayoutParams) previewVideoParent
			.getLayoutParams();
	layoutParams.width = displaymetrics.widthPixels;
	layoutParams.height = displaymetrics.widthPixels;
	previewVideoParent.setLayoutParams(layoutParams);
	
	surfaceView.setSurfaceTextureListener(this);
	surfaceView.setOnClickListener(this);
	
	path = getIntent().getStringExtra("path");
	
	imagePlay = (ImageView) findViewById(R.id.previre_play);
	imagePlay.setOnClickListener(this);
	
	mediaPlayer = new MediaPlayer();
	mediaPlayer.setOnCompletionListener(this);
}
 
Example 10
Source File: Dialog.java    From image-zoom-view with Apache License 2.0 5 votes vote down vote up
/**
 * Use for show full screen ImageViewZoom
 */
public void createFullScreenDialogFragment() {
    root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    getDialog().setContentView(root);
    getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));

    getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

}
 
Example 11
Source File: UIFlexListView.java    From Auie with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 构建内容视图
 */
private void createContentView() {
	mContentLayout = new RelativeLayout(getContext());
	mContentLayout.setId(1992);
	mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	mHeaderView = new FrameLayout(getContext());
	mHeaderView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.MATCH_PARENT));
	mHeaderView.setBackgroundColor(Color.WHITE);
	mHeaderView.setPadding(0, headerHeight, 0, 0);
	mListView = new UIListView(getContext());
	mListView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	mListView.setType(UIListView.TYPE_NONE);
	mListView.addHeaderView(mHeaderView);
	mListView.setBackgroundColor(Color.WHITE);
	mListView.setOnScrollListener(this);
	mHeaderLayout = new LinearLayout(getContext());
	mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
	mHeaderLayout.setBackgroundColor(Color.WHITE);
	mHeaderLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	mHeaderLayout.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
		@Override
		public void onGlobalLayout() {
			headerHeight = mHeaderLayout.getHeight();
			resetHeaderView(headerHeight);
		}
	});
	mHeaderContentLayout = new LinearLayout(getContext());
	mHeaderContentLayout.setOrientation(LinearLayout.VERTICAL);
	mHeaderContentLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	mHeaderActionBarLayout = new LinearLayout(getContext());
	mHeaderActionBarLayout.setBackgroundColor(Color.GRAY);
	mHeaderActionBarLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	mHeaderLayout.addView(mHeaderContentLayout);
	mHeaderLayout.addView(mHeaderActionBarLayout);
	mContentLayout.addView(mListView);
	addView(mContentLayout);
	addView(mHeaderLayout);
}
 
Example 12
Source File: BackdropBottomSheetManager.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@Override
public RelativeLayout createViewInstance(ThemedReactContext context) {
    RelativeLayout view = new RelativeLayout(context);
    int width  = CoordinatorLayout.LayoutParams.MATCH_PARENT;
    int height = CoordinatorLayout.LayoutParams.MATCH_PARENT;

    CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(width, height);
    params.setBehavior(new BackdropBottomSheetBehavior(context, null));
    view.setLayoutParams(params);
    return view;
}
 
Example 13
Source File: ExtendedCalendarView.java    From ExtendedCalendarView with Apache License 2.0 4 votes vote down vote up
private void init(){
	cal = Calendar.getInstance();
	base = new RelativeLayout(context);
	base.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
	base.setMinimumHeight(50);
	
	base.setId(4);
	
	LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.leftMargin = 16;
	params.topMargin = 50;
	params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	prev = new ImageView(context);
	prev.setId(1);
	prev.setLayoutParams(params);
	prev.setImageResource(R.drawable.navigation_previous_item);
	prev.setOnClickListener(this);
	base.addView(prev);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.addRule(RelativeLayout.CENTER_HORIZONTAL);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	month = new TextView(context);
	month.setId(2);
	month.setLayoutParams(params);
	month.setTextAppearance(context, android.R.attr.textAppearanceLarge);
	month.setText(cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault())+" "+cal.get(Calendar.YEAR));
	month.setTextSize(25);
	
	base.addView(month);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.rightMargin = 16;
	params.topMargin = 50;
	params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	next = new ImageView(context);
	next.setImageResource(R.drawable.navigation_next_item);
	next.setLayoutParams(params);
	next.setId(3);
	next.setOnClickListener(this);
	
	base.addView(next);
	
	addView(base);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.bottomMargin = 20;
	params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	params.addRule(RelativeLayout.BELOW, base.getId());
	
	calendar = new GridView(context);
	calendar.setLayoutParams(params);
	calendar.setVerticalSpacing(4);
	calendar.setHorizontalSpacing(4);
	calendar.setNumColumns(7);
	calendar.setChoiceMode(GridView.CHOICE_MODE_SINGLE);
	calendar.setDrawSelectorOnTop(true);
	
	mAdapter = new CalendarAdapter(context,cal);
	calendar.setAdapter(mAdapter);
	calendar.setOnTouchListener(new OnTouchListener() {
		
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return calendarGesture.onTouchEvent(event);
        }
    });
	
	addView(calendar);
}
 
Example 14
Source File: BaseMessageDialog.java    From Leanplum-Android-SDK with Apache License 2.0 4 votes vote down vote up
protected BaseMessageDialog(Activity activity, boolean fullscreen, BaseMessageOptions options,
    WebInterstitialOptions webOptions, HTMLOptions htmlOptions) {
  super(activity, getTheme(activity));

  SizeUtil.init(activity);
  this.activity = activity;
  this.options = options;
  this.webOptions = webOptions;
  this.htmlOptions = htmlOptions;
  if (webOptions != null) {
    isWeb = true;
  }
  if (htmlOptions != null) {
    isHtml = true;
  }
  dialogView = new RelativeLayout(activity);
  RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  dialogView.setBackgroundColor(Color.TRANSPARENT);
  dialogView.setLayoutParams(layoutParams);

  RelativeLayout view = createContainerView(activity, fullscreen);
  view.setId(R.id.container_view);
  dialogView.addView(view, view.getLayoutParams());

  if ((!isWeb || (webOptions != null && webOptions.hasDismissButton())) && !isHtml) {
    CloseButton closeButton = createCloseButton(activity, fullscreen, view);
    dialogView.addView(closeButton, closeButton.getLayoutParams());
  }
  setContentView(dialogView, dialogView.getLayoutParams());

  dialogView.setAnimation(createFadeInAnimation());

  if (!fullscreen) {
    Window window = getWindow();
    if (window == null) {
      return;
    }
    if (!isHtml) {
      window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
      if (Build.VERSION.SDK_INT >= 14) {
        window.setDimAmount(0.7f);
      }
    } else {
      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

      if (htmlOptions != null && isBannerWithTapOutsideFalse(htmlOptions)) {
        // banners need to be positioned at the top manually
        // (unless they get repositioned to the bottom later)
        window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        window.setGravity(Gravity.TOP);

        // use the html y offset to determine the y location of the window; this is different
        // from non-banners because we don't want to make the window too big (e.g. via a margin
        // in the layout) and block other things on the screen (e.g. dialogs)
        WindowManager.LayoutParams windowLayoutParams = window.getAttributes();
        windowLayoutParams.y = htmlOptions.getHtmlYOffset(activity);
        window.setAttributes(windowLayoutParams);

        window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
      } else {
        window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
      }

      if (htmlOptions != null &&
          MessageTemplates.Args.HTML_ALIGN_BOTTOM.equals(htmlOptions.getHtmlAlign())) {
        if (isBannerWithTapOutsideFalse(htmlOptions)) {
          window.setGravity(Gravity.BOTTOM);
        } else {
          dialogView.setGravity(Gravity.BOTTOM);
        }
      }
    }
  }
}
 
Example 15
Source File: CustomHintContentHolder.java    From hintcase with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(Context context, final HintCase hintCase, ViewGroup parent) {
    this.hintCase = hintCase;
    this.parent = parent;

    calculateDataToPutTheArroW(hintCase);
    setArrow(context);

    FrameLayout.LayoutParams frameLayoutParamsBlock = getParentLayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT,
            gravity, marginLeft, marginTop, marginRight, marginBottom);

    RelativeLayout fullBlockLayout = new RelativeLayout(context);
    fullBlockLayout.setLayoutParams(frameLayoutParamsBlock);

    RelativeLayout.LayoutParams relativeLayoutParamsLinear =
            new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
    for (int rule : alignBlockRules) {
        relativeLayoutParamsLinear.addRule(rule);
    }
    relativeLayoutParamsLinear.topMargin = contentTopMargin;
    relativeLayoutParamsLinear.bottomMargin = contentBottomMargin;
    relativeLayoutParamsLinear.rightMargin = contentRightMargin;
    relativeLayoutParamsLinear.leftMargin = contentLeftMargin;
    contentLinearLayout = new LinearLayout(context);
    contentLinearLayout.setBackgroundResource(R.drawable.bubble_border_background);
    LayerDrawable layerDrawable = (LayerDrawable) contentLinearLayout.getBackground().getCurrent();
    GradientDrawable gradientDrawable = (GradientDrawable) layerDrawable.getDrawable(layerDrawable.getNumberOfLayers() - 1);
    gradientDrawable.setColor(backgroundColor);
    if (useBorder) {
        gradientDrawable.setStroke(borderSize, borderColor);
    }

    contentLinearLayout.setLayoutParams(relativeLayoutParamsLinear);
    contentLinearLayout.setGravity(Gravity.CENTER);
    int padding = borderSize + shadowSize;
    contentLinearLayout.setPadding(padding + contentLeftPadding,
            padding + contentTopPadding,
            padding + contentRightPadding,
            padding + contentBottomPadding);
    contentLinearLayout.setOrientation(LinearLayout.VERTICAL);

    if (contentTitle != null) {
        contentLinearLayout.addView(getTextViewTitle(context));
    }
    if (existImage()) {
        contentLinearLayout.addView(getImage(context, imageView, imageResourceId));
    }
    if (contentText != null) {
        contentLinearLayout.addView(getTextViewDescription(context));
    }
    fullBlockLayout.addView(contentLinearLayout);
    fullBlockLayout.addView(arrow);
    return fullBlockLayout;
}
 
Example 16
Source File: EmptyLayout.java    From AndroidEmptyLayout with Apache License 2.0 4 votes vote down vote up
private void changeEmptyType() {

        setDefaultValues();
        refreshMessages();

        // insert views in the root view
        if (!mViewsAdded) {
            RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            lp.addRule(RelativeLayout.CENTER_IN_PARENT);
            mEmptyRelativeLayout = new RelativeLayout(getContext());
            mEmptyRelativeLayout.setGravity(Gravity.CENTER);
            mEmptyRelativeLayout.setLayoutParams(lp);
            if (mEmptyView!=null) mEmptyRelativeLayout.addView(mEmptyView);
            if (mLoadingView!=null) mEmptyRelativeLayout.addView(mLoadingView);
            if (mErrorView!=null) mEmptyRelativeLayout.addView(mErrorView);
            mViewsAdded = true;
            mEmptyRelativeLayout.setVisibility(VISIBLE);
            addView(mEmptyRelativeLayout);
        }


        // change empty type
            View loadingAnimationView = null;
            if (mLoadingAnimationViewId > 0) loadingAnimationView = findViewById(mLoadingAnimationViewId);
            switch (mEmptyType) {
                case TYPE_EMPTY:
                    if (mEmptyView!=null) mEmptyView.setVisibility(View.VISIBLE);
                    if (mErrorView!=null) mErrorView.setVisibility(View.GONE);
                    if (mLoadingView!=null) {
                        mLoadingView.setVisibility(View.GONE);
                        if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel();
                    }
                    break;
                case TYPE_ERROR:
                    if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE);
                    if (mErrorView!=null) mErrorView.setVisibility(View.VISIBLE);
                    if (mLoadingView!=null) {
                        mLoadingView.setVisibility(View.GONE);
                        if (loadingAnimationView!=null && loadingAnimationView.getAnimation()!=null) loadingAnimationView.getAnimation().cancel();
                    }
                    break;
                case TYPE_LOADING:
                    if (mEmptyView!=null) mEmptyView.setVisibility(View.GONE);
                    if (mErrorView!=null) mErrorView.setVisibility(View.GONE);
                    if (mLoadingView!=null) {
                        mLoadingView.setVisibility(View.VISIBLE);
                        if (mLoadingAnimation != null && loadingAnimationView!=null) {
                            loadingAnimationView.startAnimation(mLoadingAnimation);
                        }
                        else if (loadingAnimationView!=null) {
                            loadingAnimationView.startAnimation(getRotateAnimation());
                        }
                    }
                    break;
                default:
                    break;
            }
    }
 
Example 17
Source File: RichEditText.java    From RichEditText with Apache License 2.0 4 votes vote down vote up
private void setupView(Context context, AttributeSet attrs, int defStyleAttr,int defStyleRes){
        _context = context;
        RelativeLayout relativeLayout = new RelativeLayout(context);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT);

        EditText editText = new EditText(context,attrs);

        editText.setId(EDIT_TEXT_ID);
        //
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RichEditText);
        mRichEditEnabled = a.getBoolean(R.styleable.RichEditText_richEditAble,true);
        a.recycle();

        mImageButton = new ImageButton(context);
        int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics());
        RelativeLayout.LayoutParams editToggleParams = new RelativeLayout.LayoutParams(px,px);
        mImageButton.setBackground(getResources().getDrawable(R.drawable.ic_keyboard_arrow_left_black_24dp));
        editToggleParams.addRule(RelativeLayout.ALIGN_BOTTOM, EDIT_TEXT_ID);
        editToggleParams.addRule(RelativeLayout.ALIGN_RIGHT, EDIT_TEXT_ID);
        mImageButton.setLayoutParams(editToggleParams);
        mImageButton.setId(EDIT_TOGGLE_ID);
        mImageButton.setRotation(-90);
        mImageButton.setOnClickListener(this);

        View htmlOptions = inflate(context,R.layout.htmloptions,null);

        RelativeLayout.LayoutParams htmlOptionsLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);

        htmlOptionsLayoutParams.addRule(RelativeLayout.BELOW, 1001);
        htmlOptionsLayoutParams.addRule(RelativeLayout.ALIGN_RIGHT, 1001);

        htmlOptions.setLayoutParams(htmlOptionsLayoutParams);
        relativeLayout.setLayoutParams(params);
        relativeLayout.addView(editText);
        relativeLayout.addView(mImageButton);

        //htmlOptions.setVisibility(View.GONE);
        if(mRichEditEnabled) {
            relativeLayout.addView(htmlOptions);
        }
        addView(relativeLayout);

        this.mEditText = editText;
        if(mRichEditEnabled) {
            findViewById(R.id.makeBold).setOnClickListener(this);
            findViewById(R.id.makeItalic).setOnClickListener(this);
            findViewById(R.id.makeUnderline).setOnClickListener(this);
            findViewById(R.id.makeBackground).setOnClickListener(this);
            findViewById(R.id.makeForeground).setOnClickListener(this);
            findViewById(R.id.makeHyperlink).setOnClickListener(this);
            findViewById(R.id.makeStrikethrough).setOnClickListener(this);
            findViewById(R.id.makeScaleX).setOnClickListener(this);
            mHtmloptions = (LinearLayout) findViewById(R.id.rich_toolbar);
            mHtmloptions.setVisibility(View.GONE);
//            mImageButton = (ImageButton) findViewById(R.id.list_toggle);
//            mImageButton.setOnClickListener(this);
        }
        this.mEditText.setOnClickListener(this);
        setOnClickListener(this);
        mSS = new SpannableStringBuilder(mEditText.getText());

    }
 
Example 18
Source File: PreviewControllerView.java    From YImagePicker with Apache License 2.0 4 votes vote down vote up
/**
 * 获取预览的fragment里的布局
 *
 * @param fragment 当前加载的fragment,可以使用以下方式来绑定生命周期
 * <p>
 *         fragment.getLifecycle().addObserver(new ILifeCycleCallBack() {
 *             public void onResume() {}
 *             public void onPause() {}
 *             public void onDestroy() {}
 *         });
 *</p>
 *
 * @param imageItem  当前加载imageitem
 * @param presenter presenter
 * @return 预览的布局
 */
public View getItemView(Fragment fragment, final ImageItem imageItem, IPickerPresenter presenter) {
    if (imageItem == null) {
        return new View(fragment.getContext());
    }

    RelativeLayout layout = new RelativeLayout(getContext());
    final CropImageView imageView = new CropImageView(getContext());
    imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    // 启用图片缩放功能
    imageView.setBounceEnable(true);
    imageView.enable();
    imageView.setShowImageRectLine(false);
    imageView.setCanShowTouchLine(false);
    imageView.setMaxScale(7.0f);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(params);
    layout.setLayoutParams(params);
    layout.addView(imageView);

    ImageView mVideoImg = new ImageView(getContext());
    mVideoImg.setImageDrawable(getResources().getDrawable(R.mipmap.picker_icon_video));
    RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(PViewSizeUtils.dp(getContext(), 80), PViewSizeUtils.dp(getContext(), 80));
    mVideoImg.setLayoutParams(params1);
    params1.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(mVideoImg, params1);

    if (imageItem.isVideo()) {
        mVideoImg.setVisibility(View.VISIBLE);
    } else {
        mVideoImg.setVisibility(View.GONE);
    }

    imageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (imageItem.isVideo()) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                intent.setDataAndType(imageItem.getUri(), "video/*");
                getContext().startActivity(intent);
                return;
            }
            singleTap();
        }
    });
    DetailImageLoadHelper.displayDetailImage(false, imageView, presenter, imageItem);
    return layout;
}
 
Example 19
Source File: Banner.java    From MaterialBanner with Apache License 2.0 4 votes vote down vote up
private void initViewGroup(Context context) {
    // CONTENT CONTAINER
    LayoutParams layoutParams = new LayoutParams(MATCH_PARENT, WRAP_CONTENT);

    mContentContainer = new RelativeLayout(context);
    mContentContainer.setId(R.id.mb_container_content);
    mContentContainer.setLayoutParams(layoutParams);

    // ICON VIEW
    RelativeLayout.LayoutParams relativeLayoutParams = new RelativeLayout.LayoutParams(
            mIconSize, mIconSize);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        relativeLayoutParams.setMarginStart(mIconMarginStart);
        relativeLayoutParams.addRule(ALIGN_PARENT_START, TRUE);
    } else {
        relativeLayoutParams.leftMargin = mIconMarginStart;
        relativeLayoutParams.addRule(ALIGN_PARENT_LEFT, TRUE);
    }

    mIconView = new AppCompatImageView(context);
    mIconView.setId(R.id.mb_icon);
    mIconView.setLayoutParams(relativeLayoutParams);
    mIconView.setVisibility(GONE);

    // MESSAGE VIEW
    relativeLayoutParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        relativeLayoutParams.setMarginStart(mMessageMarginStart);
        relativeLayoutParams.addRule(ALIGN_PARENT_START, TRUE);
    } else {
        relativeLayoutParams.leftMargin = mMessageMarginStart;
        relativeLayoutParams.addRule(ALIGN_PARENT_LEFT, TRUE);
    }

    mMessageView = new MessageView(context);
    mMessageView.setId(R.id.mb_message);
    mMessageView.setLayoutParams(relativeLayoutParams);

    // BUTTONS CONTAINER
    relativeLayoutParams = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        relativeLayoutParams.addRule(ALIGN_PARENT_END, TRUE);
    } else {
        relativeLayoutParams.addRule(ALIGN_PARENT_RIGHT, TRUE);
    }

    mButtonsContainer = new ButtonsContainer(context);
    mButtonsContainer.setId(R.id.mb_container_buttons);
    mButtonsContainer.setLayoutParams(relativeLayoutParams);

    mLeftButton = mButtonsContainer.getLeftButton();
    mRightButton = mButtonsContainer.getRightButton();

    // LINE
    layoutParams = new LayoutParams(MATCH_PARENT, mLineHeight);

    mLine = new View(context);
    mLine.setId(R.id.mb_line);
    mLine.setLayoutParams(layoutParams);

    addView(mContentContainer);
    addView(mLine);

    mContentContainer.addView(mIconView);
    mContentContainer.addView(mMessageView);
    mContentContainer.addView(mButtonsContainer);
}
 
Example 20
Source File: PlayActivity.java    From FixMath with Apache License 2.0 2 votes vote down vote up
public void CalcClick(View view){
    clicked = true;
    isKeyboradOpen = true;
    ClickOn = view.getId();
    //FIELD TO CLOSE KEYBORAD
    CloseKeyboardNextTo();

    //FIGURE ANIMATION


    animClickFigures(view.getTag().toString());



    //      KEYBOARD
    RelativeLayout keyobard1 = (RelativeLayout)findViewById(R.id.keyboard);
    View key = findViewById(R.id.keyboard);
    setClickableRecursive(key, true);

    //Keyboard animation
    SameLineKeyAnim(view);

    RelativeLayout.LayoutParams keyboardParams = (RelativeLayout.LayoutParams)keyobard1.getLayoutParams();

    //RESET KEYBOARD
    keyboardParams.addRule(RelativeLayout.BELOW);
    keyboardParams.addRule(RelativeLayout.ABOVE);
    keyobard1.setLayoutParams(keyboardParams);



    SetVisibleKeyboard();

    //COLOR KEYBOARD
    SetKeyboardView(view);

    int ID, on;

    outerloop:
    for (int i = 1; i <= 5; i++){
        for (int z = 0; z <= 4; z++) {
            String TextViewId = "var" + i + "x" + z;
            ID = getResources().getIdentifier(TextViewId, "id", getPackageName());
            TextView xt = (TextView) findViewById(ID);
            on = xt.getId();

            if (ClickOn == on){

                TextViewX = i;
                TextViewY = z;
                break outerloop;
            }
        }
    }


}