Example usage for android.widget RelativeLayout ALIGN_PARENT_RIGHT

List of usage examples for android.widget RelativeLayout ALIGN_PARENT_RIGHT

Introduction

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

Prototype

int ALIGN_PARENT_RIGHT

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

Click Source Link

Document

Rule that aligns the child's right edge with its RelativeLayout parent's right 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 {/*w w  w  .  j av  a 2s  . 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: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/*from  w w  w . ja  v  a2s . 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  w w w.  j  a  va  2s. com*/
        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: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  ww .  ja  v  a2s  . 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:id.co.datascrip.dtswarehousesystem.activity.Form_Scan_Scandid.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    bundle = getIntent().getBundleExtra("bundle");
    initScanner();//from   w  w w.j a va2 s .  c om

    RelativeLayout overlayView = mPicker.getOverlayView();
    final FloatingActionButton floatingActionButton = new FloatingActionButton(this);
    floatingActionButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_create_white_18dp));

    ShitTextView tx_title = new ShitTextView(this);
    tx_title.setText(bundle.getString("TitleScan"));
    ShitTextView tx_input_manual = new ShitTextView(this);
    tx_input_manual.setText(bundle.getString("TitleInput").trim().replace(":", ""));

    floatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Dialog_Input_Manual dialog = new Dialog_Input_Manual(Form_Scan_Scandid.this, bundle);
            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    if (!Function.isEmpty(no)) {
                        Intent intent = new Intent();
                        intent.putExtra(getString(R.string.intent_result_scan), no);
                        setResult(RESULT_OK, intent);
                        no = "";
                        finish();
                    }
                }
            });
        }
    });

    RelativeLayout.LayoutParams rParams = new RelativeLayout.LayoutParams(
            AppBarLayout.LayoutParams.WRAP_CONTENT, AppBarLayout.LayoutParams.WRAP_CONTENT);
    rParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    rParams.topMargin = 60;
    rParams.rightMargin = 20;

    RelativeLayout.LayoutParams infoParam = new RelativeLayout.LayoutParams(
            AppBarLayout.LayoutParams.WRAP_CONTENT, AppBarLayout.LayoutParams.WRAP_CONTENT);
    infoParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    infoParam.topMargin = 20;
    infoParam.rightMargin = 10;
    tx_input_manual.setTextColor(ContextCompat.getColor(this, R.color.GREEN));
    tx_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Felbridge-Light.otf"));

    RelativeLayout.LayoutParams titleParam = new RelativeLayout.LayoutParams(
            AppBarLayout.LayoutParams.MATCH_PARENT, AppBarLayout.LayoutParams.WRAP_CONTENT);
    titleParam.topMargin = 300;
    titleParam.leftMargin = 50;
    tx_title.setTextSize(24);
    tx_title.setTextColor(ContextCompat.getColor(this, R.color.GREEN));
    tx_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Felbridge-Bold.otf"));

    overlayView.addView(floatingActionButton, rParams);
    overlayView.addView(tx_input_manual, infoParam);
    overlayView.addView(tx_title, titleParam);
}

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();// w  ww. j  a  v a 2s.c  om

    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.ohso.util.ImageHandler.java

public ImageHandler(Activity activity) {
    MEMORY_CLASS = ((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    MEMORY_CACHE_SIZE = 1024 * 1024 * MEMORY_CLASS / 8; // Use 1/8 the available memory
    mMemoryCache = new LruCache<String, Bitmap>(MEMORY_CACHE_SIZE) {
        protected int sizeOf(String key, Bitmap bitmap) {
            return bitmap.getRowBytes() * bitmap.getHeight();
        }// w  w w . java2 s  .c o  m
    };
    File cacheDir = new File(activity.getCacheDir(), "thumbnails");
    try {
        mDiskCache = DiskLruCache.open(cacheDir, 1, 1, DISK_CACHE_SIZE);
    } catch (IOException e) {
        e.printStackTrace();
    }
    mPixelSize = scaledDIP(IMAGE_DIMENSIONS);
    mPlaceholderParams = new RelativeLayout.LayoutParams((int) mPixelSize, (int) mPixelSize);
    mPlaceholderParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mPlaceholderParams.topMargin = 0;
}

From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java

/**
 *    Helper for overlaying patch button setup over tab button
 *///from   w ww  .j  a v a  2s  .c  o  m
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    int[] a = new int[2];
    btSetup.getLocationOnScreen(a);
    btSetup.setWidth(mTabHost.getTabWidget().getChildAt(4).getWidth());
    btSetup.setHeight(mTabHost.getTabWidget().getChildAt(4).getHeight());

    if (a[0] == 0) {
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) btSetup.getLayoutParams();
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        params.setMargins(1, 0, 0, 1);
        btSetup.setLayoutParams(params);
    }

    btSetup.bringToFront();
    btSetup.invalidate();
}

From source file:dhbk.android.spotifygcs.ui.fab.FABRevealLayout.java

private void setupFABPosition() {
    LayoutParams params = (LayoutParams) fab.getLayoutParams();
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        params.rightMargin = dipsToPixels(16);
        params.topMargin = dipsToPixels(20);
    }//from  ww  w . ja  v  a 2 s  .com
    fab.bringToFront();
}