List of usage examples for android.widget RelativeLayout ALIGN_PARENT_TOP
int ALIGN_PARENT_TOP
To view the source code for android.widget RelativeLayout ALIGN_PARENT_TOP.
Click Source Link
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 w w w .ja v a2 s . c om*/ 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);/* w w w.ja v a 2 s . com*/ }
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. j a v a 2s .c o m protected void clicked() { // REMOVE presenter.onOkButtonClick(); } }; }
From source file:fm.feed.android.testapp.fragment.SlidingFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { RelativeLayout rootView = (RelativeLayout) inflater.inflate(R.layout.fragment_sliding, container, false); /**// w w w . j a v a 2s . c o m * Override default PlayerView Shared Subject title */ PlayerView playerView = (PlayerView) rootView.findViewById(R.id.player); playerView.setShareSubject("Currently listening from a sliding panel!"); int margin = (int) UIUtils.convertDpToPixel(getActivity(), getResources().getDimension(R.dimen.player_padding)); int sizeBaseline = (int) UIUtils.convertDpToPixel(getActivity(), DEFAULT_SVG_SIZE_DP) + margin * 2; SVGImageView closeButton = new SVGImageView(getActivity()); try { closeButton.setSVG(SVG.getFromResource(getActivity(), R.drawable.ic_backarrow_normal)); closeButton.setContentDescription(getString(R.string.accessibility_back)); } catch (SVGParseException e) { e.printStackTrace(); } RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(sizeBaseline, sizeBaseline); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); closeButton.setLayoutParams(layoutParams); closeButton.setScaleType(ImageView.ScaleType.FIT_START); int padding = sizeBaseline / 4; closeButton.setPadding(margin, margin, margin, margin); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().onBackPressed(); } }); playerView.addView(closeButton); return rootView; }
From source file:com.bluekai.sdk.BlueKaiViewDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); if (blueKaiView == null) { blueKaiView = new WebView(getActivity()); WebViewClient client = new WebViewClient() { @Override/*from w ww . j av a2s . co m*/ public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); Logger.debug("BlueKaiView", "Error loading BK URL in webview -- " + errorCode + " -- " + description); errorOccured = true; if (listener != null) { listener.onViewLoaded(false, isExistingData(), getParamsList()); } } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (!errorOccured && listener != null) { errorOccured = false; listener.onViewLoaded(true, isExistingData(), getParamsList()); } } }; blueKaiView.setWebViewClient(client); WebSettings webSettings = blueKaiView.getSettings(); webSettings.setJavaScriptEnabled(true); int height = 1, width = 1; // if (devMode) { height = width = 300; // } RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); params.setMargins(10, 10, 10, 10); blueKaiView.setLayoutParams(params); blueKaiView.setBackgroundColor(Color.LTGRAY); alertDialogBuilder.setNegativeButton("Close", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); } blueKaiView.loadUrl(url); alertDialogBuilder.setView(blueKaiView); return alertDialogBuilder.create(); }
From source file:fm.feed.android.playersdk.fragment.SlidingPlayerFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { RelativeLayout rootView = (RelativeLayout) inflater.inflate(R.layout.feed_fm_sliding_player_fragment, container, false);/*from w ww . ja va2 s .co m*/ /** * Override default PlayerView Shared Subject title */ PlayerView playerView = (PlayerView) rootView.findViewById(R.id.player); playerView.setShareSubject("Currently listening from a sliding panel!"); int margin = (int) UIUtils.convertDpToPixel(getActivity(), getResources().getDimension(R.dimen.player_padding)); int sizeBaseline = (int) UIUtils.convertDpToPixel(getActivity(), DEFAULT_SVG_SIZE_DP) + margin * 2; SVGImageView closeButton = new SVGImageView(getActivity()); try { closeButton.setSVG(SVG.getFromResource(getActivity(), R.drawable.ic_backarrow_normal)); closeButton.setContentDescription(getString(R.string.accessibility_back)); } catch (SVGParseException e) { e.printStackTrace(); } RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(sizeBaseline, sizeBaseline); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); closeButton.setLayoutParams(layoutParams); closeButton.setScaleType(ImageView.ScaleType.FIT_START); int padding = sizeBaseline / 4; closeButton.setPadding(margin, margin, margin, margin); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().onBackPressed(); } }); playerView.addView(closeButton); return rootView; }
From source file:com.sahana.geosmser.view.ReverseGeocoderView.java
public void initialUIComponent() { mTextView = new TextView(mContext); mEditText = new EditText(mContext); mButton = new Button(mContext); mTextView.setId(3);//w w w.j a v a2 s. c o m mEditText.setId(1); mButton.setId(2); mTextView.setText(""); mEditText.setHint("EX: ???"); mButton.setText(""); RelativeLayout.LayoutParams mTextLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams mEditLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams mButtonLayoutParams = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mTextLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); mEditLayoutParams.addRule(BELOW, mTextView.getId()); mButtonLayoutParams.addRule(RIGHT_OF, mEditText.getId()); mButtonLayoutParams.addRule(ALIGN_BASELINE, mEditText.getId()); mButton.setOnClickListener(getGeocoder); this.addView(mTextView, mTextLayoutParams); this.addView(mEditText, mEditLayoutParams); this.addView(mButton, mButtonLayoutParams); }
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. jav a 2 s. c o m*/ fab.bringToFront(); }
From source file:com.truizlop.fabreveallayout.FABRevealLayout.java
private void setupFABPosition() { RelativeLayout.LayoutParams params = (RelativeLayout.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 w w w .ja v a2 s .c o m fab.bringToFront(); }