Example usage for android.widget RelativeLayout RelativeLayout

List of usage examples for android.widget RelativeLayout RelativeLayout

Introduction

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

Prototype

public RelativeLayout(Context context) 

Source Link

Usage

From source file:com.ab.activity.AbActivity.java

/**
 * ??.//from   w w w . j a  v  a2 s  .  co  m
 *
 * @param savedInstanceState the saved instance state
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mInflater = LayoutInflater.from(this);

    //?
    mAbTitleBar = new AbTitleBar(this);

    //
    ab_base = new RelativeLayout(this);
    ab_base.setBackgroundColor(Color.rgb(255, 255, 255));

    //
    contentLayout = new RelativeLayout(this);
    contentLayout.setPadding(0, 0, 0, 0);

    //?
    mAbBottomBar = new AbBottomBar(this);

    //View
    ab_base.addView(mAbTitleBar,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mAbTitleBar.setVisibility(View.GONE);

    RelativeLayout.LayoutParams layoutParamsBottomBar = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsBottomBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    ab_base.addView(mAbBottomBar, layoutParamsBottomBar);

    RelativeLayout.LayoutParams layoutParamsContent = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsContent.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
    layoutParamsContent.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
    ab_base.addView(contentLayout, layoutParamsContent);

    //Application?
    abApplication = getApplication();

    //ContentView
    setContentView(ab_base,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}

From source file:com.cloudkick.CheckViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CheckViewState previousState = (CheckViewState) getLastNonConfigurationInstance();
    if (previousState != null) {
        nodeName = previousState.nodeName;
        nodeId = previousState.nodeId;//from  w  w  w.  ja  va2 s. c om
        checkId = previousState.checkId;
        check = previousState.check;
    } else {
        Bundle data = this.getIntent().getExtras();
        nodeName = (String) data.getSerializable("nodeName");
        nodeId = (String) data.getSerializable("nodeId");
        checkId = (String) data.getSerializable("checkId");
        check = (Check) data.getSerializable("check");
    }

    String inflater = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater li = (LayoutInflater) getSystemService(inflater);

    checkView = new RelativeLayout(this);
    li.inflate(R.layout.check_view, checkView, true);
    setContentView(checkView);

    setTitle(nodeName + ": " + check.type + " check");
    redrawCheck();
    reloadAPI();
}

From source file:com.bangqu.eshow.activity.ESActivity.java

/**
 * ??.//  w w  w .  j  ava 2 s .c  o  m
 *
 * @param savedInstanceState the saved instance state
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mInflater = LayoutInflater.from(this);

    //?
    mAbTitleBar = new ESTitleBar(this);

    //
    ab_base = new RelativeLayout(this);
    ab_base.setBackgroundColor(Color.rgb(255, 255, 255));

    //
    contentLayout = new RelativeLayout(this);
    contentLayout.setPadding(0, 0, 0, 0);

    //?
    mAbBottomBar = new ESBottomBar(this);

    //View
    ab_base.addView(mAbTitleBar,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mAbTitleBar.setVisibility(View.GONE);

    RelativeLayout.LayoutParams layoutParamsBottomBar = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsBottomBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    ab_base.addView(mAbBottomBar, layoutParamsBottomBar);

    RelativeLayout.LayoutParams layoutParamsContent = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsContent.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
    layoutParamsContent.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
    ab_base.addView(contentLayout, layoutParamsContent);

    //Application?
    abApplication = getApplication();

    //ContentView
    setContentView(ab_base,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    ESActivityManager.getInstance().addActivity(this);
}

From source file:cn.org.eshow.framwork.activity.AbActivity.java

/**
 * ??./*from w w  w.j  a  v a  2 s.co  m*/
 *
 * @param savedInstanceState the saved instance state
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    mInflater = LayoutInflater.from(this);

    //?
    mAbTitleBar = new AbTitleBar(this);

    //
    ab_base = new RelativeLayout(this);
    ab_base.setBackgroundColor(Color.rgb(255, 255, 255));

    //
    contentLayout = new RelativeLayout(this);
    contentLayout.setPadding(0, 0, 0, 0);

    //?
    mAbBottomBar = new AbBottomBar(this);

    //View
    ab_base.addView(mAbTitleBar,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    mAbTitleBar.setVisibility(View.GONE);

    RelativeLayout.LayoutParams layoutParamsBottomBar = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsBottomBar.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    ab_base.addView(mAbBottomBar, layoutParamsBottomBar);

    RelativeLayout.LayoutParams layoutParamsContent = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParamsContent.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
    layoutParamsContent.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
    ab_base.addView(contentLayout, layoutParamsContent);

    //Application?
    abApplication = getApplication();

    //ContentView
    setContentView(ab_base,
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    AbActivityManager.getInstance().addActivity(this);
}

From source file:com.smart.able2include.SimpleTextOverlayView.java

private void createView() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);//from   w w w  .  j a va  2  s. c o  m

    params.gravity = Gravity.START | Gravity.TOP;
    params.x = 0;
    params.y = 30;
    params.width = wm.getDefaultDisplay().getWidth();
    params.height = wm.getDefaultDisplay().getHeight() - 30;

    frameLayout = new RelativeLayout(mServiceContext);
    LayoutInflater layoutInflater = (LayoutInflater) mServiceContext
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // Here is the place where you can inject whatever layout you want.
    layoutInflater.inflate(R.layout.simpletxt_layout, frameLayout);

    TextView text = (TextView) frameLayout.findViewById(R.id.textViewSimplifiedText);
    text.setText(mSimpleText);
    dialogButton = (Button) frameLayout.findViewById(R.id.simpleButtonOK);
    // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            RemoveOvelay();
            delegate.onClick();
        }
    });
    synchronized (mSyncToken) {
        wm.addView(frameLayout, params);
        mOnTop = true;
    }
}

From source file:org.borderstone.tagtags.widgets.BGPSWidget.java

public BGPSWidget(Context context, ColumnProperties props, int ROW, int COLUMN) {
    super(context);

    setProperties(ROW, COLUMN, props, context);
    initUI();/*  www. j a  va2 s.co  m*/

    lblCoordinates = new BInfoLabel(context);

    String data = Constants.csv.getValue(row, column);

    if (data.equals("") && props.recurring && props.lastValue != null) {
        data = props.lastValue;
        updateData(data);
    } else if (!data.equals("")) {
        hasSavedData = true;
    }

    lblCoordinates.setText(data);

    if (properties.gpsGlobal) {
        lblCoordinates.setGravity(Gravity.CENTER);
        this.addView(lblCoordinates);
    } else {
        RelativeLayout rl = new RelativeLayout(context);
        RelativeLayout.LayoutParams labelParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        RelativeLayout.LayoutParams buttonParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

        labelParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        buttonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

        btnGPS = new ImageButton(context);
        btnGPS.setBackgroundResource(R.drawable.camera_button);

        btnGPS.setOnClickListener(this);
        btnGPS.setOnLongClickListener(this);

        rl.addView(lblCoordinates, labelParams);
        rl.addView(btnGPS, buttonParams);

        updateButtonDrawable();

        this.addView(rl);
    }
}

From source file:com.bilibili.socialize.share.utils.selector.PopFullScreenSharePlatformSelector.java

private void createShareWindowIfNeed() {
    if (mShareWindow != null)
        return;//from w ww. j ava  2  s .  c o  m

    Context context = getContext();

    grid = createShareGridView(context, getItemClickListener());
    RelativeLayout.LayoutParams gridParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    gridParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    grid.setLayoutParams(gridParams);

    mContainerView = new RelativeLayout(getContext());
    mContainerView.setBackgroundColor(getContext().getResources().getColor(R.color.bili_socialize_black_trans));
    RelativeLayout.LayoutParams containerParams = new RelativeLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    mContainerView.setLayoutParams(containerParams);
    mContainerView.addView(grid);
    mContainerView.setOnClickListener(this);

    mShareWindow = new PopupWindow(mContainerView, WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT, true);
    grid.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    mShareWindow.setOutsideTouchable(true);
    mShareWindow.setAnimationStyle(-1);
    mShareWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            if (getDismissListener() != null)
                getDismissListener().onDismiss();
        }
    });
}

From source file:com.eggsoftware.flingsolver.gui.DrawSolutionPageAdapter.java

@Override
public Object instantiateItem(View collection, int position) {
    // Create the "Step N of T" TextView
    TextView stepTextView = new TextView(this.context);
    stepTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    stepTextView.setTextColor(Color.rgb(113, 113, 113));
    stepTextView.setGravity(Gravity.CENTER);
    stepTextView.setText(String.format(this.context.getResources().getString(R.string.step_of), position + 1,
            this.solution.size()));

    // Create the boar with the current step of the solution
    BoardCanvas board = new BoardCanvas(this.context);
    board.setBoardRepresentation(this.solution.get(position).getBoard());
    board.setArrow(this.solution.get(position).getRow(), this.solution.get(position).getCol(),
            this.solution.get(position).getDirection());

    // Add the components to the layout
    LinearLayout layout = new LinearLayout(this.context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(16, 20, 16, 16);/*  w ww .  ja v  a 2 s .com*/

    RelativeLayout relativeLatout = new RelativeLayout(this.context);
    relativeLatout.setLayoutParams(
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
    relativeLatout.addView(board);

    layout.addView(relativeLatout);
    layout.addView(stepTextView);
    ((ViewPager) collection).addView(layout, 0);
    return layout;
}

From source file:org.projectbuendia.client.ui.ProgressFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    mFrame = new RelativeLayout(getActivity());
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    mFrame.setLayoutParams(layoutParams);

    RelativeLayout.LayoutParams relativeLayout = new RelativeLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    relativeLayout.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mIndeterminateProgressBar = new ProgressBar(getActivity());
    mIndeterminateProgressBar.setLayoutParams(relativeLayout);

    mProgressBarLayout = inflater.inflate(R.layout.progress_fragment_measured_progress_view, null);
    mProgressBarLayout.setLayoutParams(relativeLayout);
    mProgressBar = (ProgressBar) mProgressBarLayout.findViewById(R.id.progress_fragment_progress_bar);
    mProgressBarLabel = (TextView) mProgressBarLayout.findViewById(R.id.progress_fragment_label);

    RelativeLayout.LayoutParams fullLayout = new RelativeLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    fullLayout.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mErrorTextView = new TextView(getActivity());
    mErrorTextView.setLayoutParams(fullLayout);
    mErrorTextView.setGravity(Gravity.CENTER);

    mContent.setVisibility(View.GONE);
    mProgressBarLayout.setVisibility(View.GONE);
    mFrame.addView(mIndeterminateProgressBar);
    mFrame.addView(mProgressBarLayout);//  w w  w .j  ava  2s  .co m
    mFrame.addView(mContent);
    mFrame.addView(mErrorTextView);
    return mFrame;
}

From source file:com.wms.opensource.images3android.activity.ImageListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (layout != null) {
        ViewGroup parent = (ViewGroup) layout.getParent();
        parent.removeView(layout);/*from  w  w w .j  a  va  2  s.  c  o m*/
        return layout;
    }

    if (listView == null) {
        layout = new RelativeLayout(getActivity());
        listView = new ListView(getActivity());
        layout.addView(listView);

        progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge);

        // Center a view in relative layout
        RelativeLayout.LayoutParams progressBarParams = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        progressBarParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        progressBar.setLayoutParams(progressBarParams);
        progressBar.setVisibility(View.INVISIBLE);
        layout.addView(progressBar);

        // Before reloading videos, display videos if they have been saved before
        String imagesFilePath = "";
        imagesFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/"
                + PersistFileNameUtil.getImagesPersistFileName(getString(R.string.imagePlantId), page);

        boolean imagesFileExists = FileUtil.fileExist(imagesFilePath);
        if (imagesFileExists) {
            loadCachedImagesTask = new LoadCachedImagesTask(getActivity(), loadImagesHandler, progressBar,
                    getActivity().getString(R.string.ImageS3ServiceURL),
                    getActivity().getString(R.string.imagePlantId), page);
            loadCachedImagesTask.execute();
        } else {
            NetworkStatus networkStatus = NetworkUtil.getNetworkStatus(getActivity());
            if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED)
                    || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) {
                String pageToken = page == 1 ? "" : ImageListFragmentActivity.pageTokens.get(page - 1);
                loadImagesTask = new LoadImagesTask(getActivity(), loadImagesHandler,
                        getActivity().getString(R.string.ImageS3ServiceURL),
                        getActivity().getString(R.string.imagePlantId), pageToken, page);
                loadImagesTask.execute();
            } else {
                Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show();
            }
        }
    }
    return layout;
}