Example usage for android.widget RelativeLayout ALIGN_PARENT_BOTTOM

List of usage examples for android.widget RelativeLayout ALIGN_PARENT_BOTTOM

Introduction

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

Prototype

int ALIGN_PARENT_BOTTOM

To view the source code for android.widget RelativeLayout ALIGN_PARENT_BOTTOM.

Click Source Link

Document

Rule that aligns the child's bottom edge with its RelativeLayout parent's bottom edge.

Usage

From source file:Main.java

public static RelativeLayout.LayoutParams getViewPositionParams(String alignment, int offsetX, int offsetY,
        int w, int h, int below) {

    // create a layout params
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w, h);

    // alignment vertical rule
    if (alignment.contains("top")) {
        params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else if (alignment.contains("bottom")) {
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    } else {/*from   ww  w .j a  v  a2  s.  co m*/
        params.addRule(RelativeLayout.CENTER_VERTICAL);
    }

    // alignment horizontal rule
    if (alignment.contains("left")) {
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    } else if (alignment.contains("right")) {
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    } else {
        params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    }

    // set below
    if (below > 0) {
        params.addRule(RelativeLayout.BELOW, below);
    }

    return params;
}

From source file:MainActivity.java

public void goAnimate(View view) {

    ViewGroup root = (ViewGroup) findViewById(R.id.layout);
    Scene scene = new Scene(root);

    Transition transition = new ChangeBounds();
    TransitionManager.beginDelayedTransition(root, transition);

    TextView textViewTop = (TextView) findViewById(R.id.textViewTop);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textViewTop.getLayoutParams();
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
    textViewTop.setLayoutParams(params);

    TextView textViewBottom = (TextView) findViewById(R.id.textViewBottom);
    params = (RelativeLayout.LayoutParams) textViewBottom.getLayoutParams();
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 1);
    textViewBottom.setLayoutParams(params);

    TransitionManager.go(scene);//from  w ww.  jav  a 2  s .c om

}

From source file:Main.java

public static void applyAttributes(JSONObject jsonObject, RelativeLayout.LayoutParams layoutParams)
        throws JSONException {

    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, TO_LEFT_OF, RelativeLayout.LEFT_OF);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, TO_RIGHT_OF, RelativeLayout.RIGHT_OF);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, BELOW, RelativeLayout.BELOW);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, ABOVE, RelativeLayout.ABOVE);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, ALIGN_LEFT, RelativeLayout.ALIGN_LEFT);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, ALIGN_RIGHT, RelativeLayout.ALIGN_RIGHT);
    applyRelativeLayoutRuleIfExists(jsonObject, layoutParams, ALIGN_TOP, RelativeLayout.ALIGN_TOP);

    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_TOP,
            RelativeLayout.ALIGN_PARENT_TOP);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_BOTTOM,
            RelativeLayout.ALIGN_PARENT_BOTTOM);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_RIGHT,
            RelativeLayout.ALIGN_PARENT_RIGHT);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_LEFT,
            RelativeLayout.ALIGN_PARENT_LEFT);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_BASELINE, RelativeLayout.ALIGN_BASELINE);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, ALIGN_PARENT_TOP,
            RelativeLayout.ALIGN_PARENT_TOP);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, CENTER_HORIZONTAL,
            RelativeLayout.CENTER_HORIZONTAL);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, CENTER_IN_PARENT,
            RelativeLayout.CENTER_IN_PARENT);
    applyRelativeLayoutBooleanIfExists(jsonObject, layoutParams, CENTER_VERTICAL,
            RelativeLayout.CENTER_VERTICAL);
}

From source file:com.robopupu.feature.about.view.LicensesInfoFragment.java

@Override
protected void onCreateBindings() {
    super.onCreateBindings();

    webView = new WebView(getActivity());

    webViewRelativeLayout = getView(R.id.relative_layout_web_view);
    webViewClient = new DelegatedWebViewClient(presenter);
    webView.setWebViewClient(webViewClient);

    final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    webViewRelativeLayout.addView(webView, params);

    new ClickBinding(this, R.id.button_ok) {
        @Override/*  w  w  w.  j ava  2s.c o  m*/
        protected void clicked() {
            // REMOVE presenter.onOkButtonClick();
        }
    };
}

From source file:es.uma.lcc.lockpic.SelectorActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Button btnForward, btnBack, btnFaces;
    RelativeLayout layout = new RelativeLayout(this);
    layout.setBackgroundResource(R.drawable.background_gradient);

    mPath = getIntent().getStringExtra("path");

    SelectorActivityBundle bundle = (SelectorActivityBundle) getLastCustomNonConfigurationInstance();
    if (bundle != null) {
        mDrawView = new DrawView(this, mPath, false);
        mDrawView.setRectangles(bundle.getRectangles());
        mDrawView.setViewMode(bundle.getViewMode());
        mDrawView.setAspectRate(bundle.getAspectRate());
    } else {//from  ww w. ja v a 2  s . c o  m
        mDrawView = new DrawView(this, mPath, true);
    }
    mDrawView.setId(1);

    RelativeLayout.LayoutParams lpDrawView = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    lpDrawView.addRule(RelativeLayout.CENTER_VERTICAL);
    mDrawView.setLayoutParams(lpDrawView);
    layout.addView(mDrawView, lpDrawView);

    btnForward = new Button(this);
    btnForward.setText(R.string.selectorForwardButton);
    btnForward.setId(2);
    btnForward.setOnClickListener(new forwardButtonListener());
    RelativeLayout.LayoutParams lpButton = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    lpButton.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lpButton.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    layout.addView(btnForward, lpButton);

    btnBack = new Button(this);
    btnBack.setText(R.string.selectorBackButton);
    btnBack.setId(3);
    btnBack.setOnClickListener(new backButtonListener());
    lpButton = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpButton.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lpButton.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    layout.addView(btnBack, lpButton);

    btnFaces = new Button(this);
    btnFaces.setText(R.string.facesButton);
    btnFaces.setId(4);
    btnFaces.setOnClickListener(new FacesButtonListener());
    if (!isViewSelectingRegions())
        btnFaces.setVisibility(View.INVISIBLE);
    lpButton = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpButton.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    lpButton.addRule(RelativeLayout.CENTER_HORIZONTAL);
    layout.addView(btnFaces, lpButton);

    setContentView(layout);
}

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

private void createShareWindowIfNeed() {
    if (mShareWindow != null)
        return;//from   w w  w .ja va 2 s  .  c om

    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:io.imoji.sdk.ui.sample.WidgetActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getSupportActionBar().setBackgroundDrawable(
            new ColorDrawable(getResources().getColor(R.color.widget_activity_action_bar_color)));
    setContentView(R.layout.activity_widget);

    RelativeLayout container = (RelativeLayout) findViewById(R.id.widget_main_view);

    int identifier = getIntent().getIntExtra(WIDGET_IDENTIFIER, 1);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

    SearchResultAdapter.ImageLoader imageLoader = new SearchResultAdapter.ImageLoader() {
        @Override/*w  w  w. jav a  2 s  .c  o  m*/
        public void loadImage(@NonNull ImageView target, @NonNull Uri uri,
                @NonNull final SearchResultAdapter.ImageLoaderCallback callback) {
            Ion.with(target).load(uri.toString()).setCallback(new FutureCallback<ImageView>() {
                @Override
                public void onCompleted(Exception e, ImageView result) {
                    callback.updateImageView();
                }
            });
        }
    };

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    RenderingOptions renderingOptions = new RenderingOptions(
            preferences.getBoolean(getString(R.string.pref_key_sticker_borders_enabled), true)
                    ? RenderingOptions.BorderStyle.Sticker
                    : RenderingOptions.BorderStyle.None,
            RenderingOptions.ImageFormat.Png, RenderingOptions.Size.Thumbnail);
    WidgetDisplayOptions options = new WidgetDisplayOptions(renderingOptions);
    options.setIncludeRecentsAndCreate(
            preferences.getBoolean(getString(R.string.pref_key_recents_create_enabled), true));

    switch (identifier) {
    case 0:
        widget = new QuarterScreenWidget(this, options, imageLoader);
        setTitle(R.string.activity_title_quarter_screen);
        container.addView(widget, params);
        break;
    case 1:
        widget = new HalfScreenWidget(this, options, imageLoader);
        setTitle(R.string.activity_title_half_screen);
        container.addView(widget, params);
        break;
    case 2:
        widget = new FullScreenWidget(this, options, imageLoader);
        getSupportActionBar().hide();
        container.addView(widget);
        widget.setWidgetListener(new WidgetListener() {
            @Override
            public void onCloseButtonTapped() {
                NavUtils.navigateUpFromSameTask(WidgetActivity.this);
            }

            @Override
            public void onStickerTapped(Imoji imoji) {

            }
        });
        break;
    }
}

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

/**
 * ??./*from w w w  . ja v a 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 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:de.geeksfactory.opacclient.frontend.AccountListActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account_list);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    fab = (FloatingActionButton) findViewById(R.id.add_fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override//from w  w w  . jav  a  2 s.  c  o  m
        public void onClick(View v) {
            add();
        }
    });
    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();

    float density = getResources().getDisplayMetrics().density;
    float dpWidth = displayMetrics.widthPixels / density;
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Math.round(72 * density),
            Math.round(72 * density));

    if (dpWidth >= 864) {
        params.addRule(RelativeLayout.BELOW, R.id.toolbar);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        params.setMargins(0, Math.round(-36 * density), Math.round(36 * density), 0);
        ViewCompat.setElevation(fab, 4 * density);
    } else {
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        params.setMargins(0, 0, Math.round(36 * density), Math.round(36 * density));
        ViewCompat.setElevation(fab, 12 * density);
    }
    fab.setLayoutParams(params);
}

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

/**
 * ??.// ww w.ja v a2  s .c om
 *
 * @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);
}