List of usage examples for android.widget RelativeLayout ALIGN_PARENT_LEFT
int ALIGN_PARENT_LEFT
To view the source code for android.widget RelativeLayout ALIGN_PARENT_LEFT.
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 ww w .j a va2 s .c o 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: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 www .j a v 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.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); /**//from w w w . j a v a 2 s. c om * 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: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);/*w w w.j a v a2 s.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:org.borderstone.tagtags.widgets.BGPSWidget.java
public BGPSWidget(Context context, ColumnProperties props, int ROW, int COLUMN) { super(context); setProperties(ROW, COLUMN, props, context); initUI();/*from ww w . j a va2s . 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: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 ww. j av a2 s. c om*/ 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:net.xisberto.work_schedule.PeriodListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.period_list_item, null); }/*from w w w . j a v a 2s.c o m*/ final Period period = (Period) getItem(position); ((TextView) convertView.findViewById(R.id.period_label)).setText(context.getString(period.getLabelId())); ((TextView) convertView.findViewById(R.id.period_time)) .setText(period.formatTime(DateFormat.is24HourFormat(context))); CompoundButton check_alarm = (CompoundButton) convertView.findViewById(R.id.check_alarm); if (show_checkboxes) { check_alarm.setChecked(period.enabled); check_alarm.setOnClickListener(new OnClickListener() { @Override public void onClick(View check_box) { boolean isChecked = ((CompoundButton) check_box).isChecked(); period.enabled = isChecked && (period.time.getTimeInMillis() > System.currentTimeMillis()); period.setAlarm(context, true); period.persist(context); ((CompoundButton) check_box).setChecked(period.enabled); } }); } else { check_alarm.setVisibility(View.GONE); LinearLayout layout_labels = (LinearLayout) convertView.findViewById(R.id.layout_labels); LayoutParams params = (LayoutParams) layout_labels.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); layout_labels.setLayoutParams(params); } return convertView; }
From source file:com.androidhiddencamera.HiddenCameraFragment.java
/** * Add camera preview to the root of the activity layout. * * @return {@link CameraPreview} that was added to the view. */// w w w . j a v a 2 s .com private CameraPreview addPreView() { //create fake camera view CameraPreview cameraSourceCameraPreview = new CameraPreview(getActivity(), this); cameraSourceCameraPreview.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); View view = ((ViewGroup) getActivity().getWindow().getDecorView().getRootView()).getChildAt(0); if (view instanceof LinearLayout) { LinearLayout linearLayout = (LinearLayout) view; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, 1); linearLayout.addView(cameraSourceCameraPreview, params); } else if (view instanceof RelativeLayout) { RelativeLayout relativeLayout = (RelativeLayout) view; RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(1, 1); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); relativeLayout.addView(cameraSourceCameraPreview, params); } else if (view instanceof FrameLayout) { FrameLayout frameLayout = (FrameLayout) view; FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(1, 1); frameLayout.addView(cameraSourceCameraPreview, params); } else { throw new RuntimeException("Root view of the activity/fragment cannot be frame layout"); } return cameraSourceCameraPreview; }