List of usage examples for android.widget RelativeLayout RIGHT_OF
int RIGHT_OF
To view the source code for android.widget RelativeLayout RIGHT_OF.
Click Source Link
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.binomed.showtime.android.util.CineShowTimeLayoutUtils.java
public static void manageVisibiltyFieldSpeech(Context context, ImageButton button, AutoCompleteTextView text, int idRightof, int idLeftOf, int idBelow) { // Manage speech button just if package present on device PackageManager pm = context.getPackageManager(); List<ResolveInfo> activities = pm .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if (activities.size() == 0) { button.setVisibility(View.GONE); if ((text != null) && (Integer.valueOf(Build.VERSION.SDK) <= 3)) { // Manage specificity for version before 4 RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); if (idRightof != -1) { params.addRule(RelativeLayout.RIGHT_OF, idRightof); }//w ww . j a va 2 s . co m if (idLeftOf != -1) { params.addRule(RelativeLayout.LEFT_OF, idLeftOf); } if (idBelow != -1) { params.addRule(RelativeLayout.BELOW, idBelow); } text.setSingleLine(true); text.setLayoutParams(params); } } }
From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java
/** * ?//w w w .j av a2 s. com * @return */ protected Button buildForwardButton() { RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); Button forward = createButton(BUTTON_FORWARDBUTTON_ID, forwardLayoutParams, "Forward Button", ">", new View.OnClickListener() { public void onClick(View v) { goForward(); } }); return forward; }
From source file:fr.cph.stock.android.activity.AccountActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "Account Activity onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.account_activity); Bundle b = getIntent().getExtras();//from www . j a va 2 s . co m portfolio = b.getParcelable("portfolio"); errorView = (TextView) findViewById(R.id.errorMessage); totalValueView = (TextView) findViewById(R.id.totalValue); totalGainView = (TextView) findViewById(R.id.totalGain); totalPlusMinusValueView = (TextView) findViewById(R.id.totalPlusMinusValue); lastUpateView = (TextView) findViewById(R.id.lastUpdate); liquidityView = (TextView) findViewById(R.id.liquidity); yieldYearView = (TextView) findViewById(R.id.yieldYear); shareValueView = (TextView) findViewById(R.id.shareValue); gainView = (TextView) findViewById(R.id.gain2); perfView = (TextView) findViewById(R.id.perf); yieldView = (TextView) findViewById(R.id.yieldPerf); taxesView = (TextView) findViewById(R.id.taxes); RelativeLayout accLayout = (RelativeLayout) findViewById(R.id.accountsLayout); TextView recent = new TextView(getApplicationContext()); textViews = new ArrayList<TextView>(); int id = 1; int nameID = 100; int viewId1 = 500; int currencyId = 1000; for (int i = 0; i < portfolio.getAccounts().size(); i++) { Account account = portfolio.getAccounts().get(i); TextView currentAccountNameTextView = new TextView(getApplicationContext()); currentAccountNameTextView.setText(account.getName()); currentAccountNameTextView.setTextColor(Color.GRAY); currentAccountNameTextView.setId(nameID); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); currentAccountNameTextView.setLayoutParams(params); accLayout.addView(currentAccountNameTextView, params); textViews.add(currentAccountNameTextView); View viewPoint1 = new View(getApplicationContext()); viewPoint1.setId(viewId1); viewPoint1.setBackgroundColor(getResources().getColor(R.color.grey_light)); params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2); params.addRule(RelativeLayout.RIGHT_OF, nameID); params.addRule(RelativeLayout.LEFT_OF, currencyId); params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } viewPoint1.setLayoutParams(params); accLayout.addView(viewPoint1, params); TextView currentCurrencyTextView = new TextView(getApplicationContext()); currentCurrencyTextView.setText(account.getCurrency()); currentCurrencyTextView.setTextColor(Color.GRAY); currentCurrencyTextView.setId(currencyId); params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_HORIZONTAL); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } currentCurrencyTextView.setLayoutParams(params); accLayout.addView(currentCurrencyTextView, params); textViews.add(currentCurrencyTextView); View viewPoint2 = new View(getApplicationContext()); viewPoint2.setBackgroundColor(getResources().getColor(R.color.grey_light)); params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2); params.addRule(RelativeLayout.RIGHT_OF, currencyId); params.addRule(RelativeLayout.LEFT_OF, id); params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } viewPoint2.setLayoutParams(params); accLayout.addView(viewPoint2, params); TextView currentTextView = new TextView(getApplicationContext()); currentTextView.setText(account.getLiquidity()); currentTextView.setTextColor(Color.GRAY); currentTextView.setId(id); params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); currentTextView.setLayoutParams(params); recent = currentTextView; accLayout.addView(currentTextView, params); textViews.add(currentTextView); id++; nameID++; viewId1++; currencyId++; } buildUi(false); // Set context EasyTracker.getInstance().setContext(getApplicationContext()); // Instantiate the Tracker tracker = EasyTracker.getTracker(); }
From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java
/** * /*from w w w .j a va 2 s .co m*/ */ protected void buildEditText() { RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); OnKeyListener keyListener = new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(mEditText.getText().toString()); return true; } return false; } }; mEditText = createEditText(EDITTEXT_ID, textLayoutParams, true, mUrl, InputType.TYPE_TEXT_VARIATION_URI, EditorInfo.IME_ACTION_GO, keyListener); }
From source file:org.orange.querysystem.ScoresActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case PASSWORD_PROMPT: final TextView textView = new TextView(this); textView.setText("?"); textView.setTextSize(14);/*w w w. ja v a 2 s . c o m*/ textView.setId(1); final EditText editText = new EditText(this); editText.setId(2); editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); editText.setEnabled(true); editText.setCursorVisible(true); editText.setLongClickable(true); editText.setFocusable(true); editText.setTransformationMethod(PasswordTransformationMethod.getInstance()); RelativeLayout.LayoutParams tvlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams etlp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout relativeLayout = new RelativeLayout(this); tvlp.addRule(RelativeLayout.ALIGN_BASELINE, 2); etlp.addRule(RelativeLayout.RIGHT_OF, 1); relativeLayout.addView(textView, tvlp); relativeLayout.addView(editText, etlp); return new AlertDialog.Builder(this).setView(relativeLayout) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked OK so do some stuff */ if (editText.getText().toString() .equals(SettingsActivity.getAccountPassword(ScoresActivity.this))) { authenticated = true; enterActivity(); } else { editText.setText(""); Toast.makeText(ScoresActivity.this, "????", Toast.LENGTH_LONG).show(); finish(); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked cancel so do some stuff */ finish(); } }).setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { finish(); return true; } return false; } }).create(); default: return null; } }
From source file:com.morestudio.littledot.doctor.ui.messages.MessageAdapter.java
private void setPhotoSide(MessageListItemViews tagView, ArrowPosition pos) { LayoutParams lp = (LayoutParams) tagView.quickContactView.getLayoutParams(); lp.addRule(/*from w ww .j a v a 2 s. c o m*/ (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_RIGHT : RelativeLayout.ALIGN_PARENT_LEFT); lp.addRule( (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_LEFT : RelativeLayout.ALIGN_PARENT_RIGHT, 0); lp = (LayoutParams) tagView.containterBlock.getLayoutParams(); lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.LEFT_OF : RelativeLayout.RIGHT_OF, R.id.quick_contact_photo); lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.RIGHT_OF : RelativeLayout.LEFT_OF, 0); tagView.quickContactView.setPosition(pos); }
From source file:com.abcvoipsip.ui.messages.MessageAdapter.java
private void setPhotoSide(MessageListItemViews tagView, ArrowPosition pos) { LayoutParams lp = (RelativeLayout.LayoutParams) tagView.quickContactView.getLayoutParams(); lp.addRule(//from w ww.j a v a 2 s .co m (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_RIGHT : RelativeLayout.ALIGN_PARENT_LEFT); lp.addRule( (pos == ArrowPosition.LEFT) ? RelativeLayout.ALIGN_PARENT_LEFT : RelativeLayout.ALIGN_PARENT_RIGHT, 0); lp = (RelativeLayout.LayoutParams) tagView.containterBlock.getLayoutParams(); lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.LEFT_OF : RelativeLayout.RIGHT_OF, R.id.quick_contact_photo); lp.addRule((pos == ArrowPosition.LEFT) ? RelativeLayout.RIGHT_OF : RelativeLayout.LEFT_OF, 0); tagView.quickContactView.setPosition(pos); }
From source file:fr.cph.chicago.core.adapter.NearbyAdapter.java
private View handleTrains(final int position, View convertView, @NonNull final ViewGroup parent) { // Train/* w w w. ja v a2 s . c o m*/ final Station station = stations.get(position); final Set<TrainLine> trainLines = station.getLines(); TrainViewHolder viewHolder; if (convertView == null || convertView.getTag() == null) { final LayoutInflater vi = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = vi.inflate(R.layout.list_nearby, parent, false); viewHolder = new TrainViewHolder(); viewHolder.resultLayout = (LinearLayout) convertView.findViewById(R.id.nearby_results); viewHolder.stationNameView = (TextView) convertView.findViewById(R.id.station_name); viewHolder.imageView = (ImageView) convertView.findViewById(R.id.icon); viewHolder.details = new HashMap<>(); viewHolder.arrivalTime = new HashMap<>(); convertView.setTag(viewHolder); } else { viewHolder = (TrainViewHolder) convertView.getTag(); } viewHolder.stationNameView.setText(station.getName()); viewHolder.imageView .setImageDrawable(ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_train_white_24dp)); for (final TrainLine trainLine : trainLines) { if (trainArrivals.indexOfKey(station.getId()) != -1) { final List<Eta> etas = trainArrivals.get(station.getId()).getEtas(trainLine); if (etas.size() != 0) { final LinearLayout llv; boolean cleanBeforeAdd = false; if (viewHolder.details.containsKey(trainLine)) { llv = viewHolder.details.get(trainLine); cleanBeforeAdd = true; } else { final LinearLayout llh = new LinearLayout(context); llh.setOrientation(LinearLayout.HORIZONTAL); llh.setPadding(line1PaddingColor, stopsPaddingTop, 0, 0); llv = new LinearLayout(context); llv.setOrientation(LinearLayout.VERTICAL); llv.setPadding(line1PaddingColor, 0, 0, 0); llh.addView(llv); viewHolder.resultLayout.addView(llh); viewHolder.details.put(trainLine, llv); } final List<String> keysCleaned = new ArrayList<>(); for (final Eta eta : etas) { final Stop stop = eta.getStop(); final String key = station.getName() + "_" + trainLine.toString() + "_" + stop.getDirection().toString() + "_" + eta.getDestName(); if (viewHolder.arrivalTime.containsKey(key)) { final RelativeLayout insideLayout = viewHolder.arrivalTime.get(key); final TextView timing = (TextView) insideLayout.getChildAt(2); if (cleanBeforeAdd && !keysCleaned.contains(key)) { timing.setText(""); keysCleaned.add(key); } final String timingText = timing.getText() + eta.getTimeLeftDueDelay() + " "; timing.setText(timingText); } else { final LinearLayout.LayoutParams leftParam = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); final RelativeLayout insideLayout = new RelativeLayout(context); insideLayout.setLayoutParams(leftParam); final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, trainLine); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams availableParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); availableParam.addRule(RelativeLayout.RIGHT_OF, lineId); availableParam.setMargins(Util.convertDpToPixel(context, 10), 0, 0, 0); final TextView stopName = new TextView(context); final String destName = eta.getDestName() + ": "; stopName.setText(destName); stopName.setTextColor(ContextCompat.getColor(parent.getContext(), R.color.grey_5)); stopName.setLayoutParams(availableParam); int availableId = Util.generateViewId(); stopName.setId(availableId); final RelativeLayout.LayoutParams availableValueParam = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); availableValueParam.addRule(RelativeLayout.RIGHT_OF, availableId); availableValueParam.setMargins(0, 0, 0, 0); final TextView timing = new TextView(context); final String timeLeftDueDelay = eta.getTimeLeftDueDelay() + " "; timing.setText(timeLeftDueDelay); timing.setTextColor(ContextCompat.getColor(parent.getContext(), R.color.grey)); timing.setLines(1); timing.setEllipsize(TruncateAt.END); timing.setLayoutParams(availableValueParam); insideLayout.addView(lineIndication); insideLayout.addView(stopName); insideLayout.addView(timing); llv.addView(insideLayout); viewHolder.arrivalTime.put(key, insideLayout); } } } } } convertView.setOnClickListener(new NearbyOnClickListener(googleMap, markers, station.getId(), station.getStopsPosition().get(0).getLatitude(), station.getStopsPosition().get(0).getLongitude())); return convertView; }
From source file:com.ns.developer.tagview.widget.TagCloudLinkView.java
/** * tag draw//from w w w . j a v a 2s .co m */ public void drawTags() { if (!mInitialized) { return; } // clear all tag removeAllViews(); // layout padding left & layout padding right float total = getPaddingLeft() + getPaddingRight(); // ???index int index = 1; // ? int pindex = index; // List Index int listIndex = 0; for (String item : mTags) { final int position = listIndex; final String tag = item; // inflate tag layout View tagLayout = (View) mInflater.inflate(R.layout.tag, null); tagLayout.setId(index); // tagLayout.setBackgroundColor(mTagLayoutColor); // tag text TextView tagView = (TextView) tagLayout.findViewById(R.id.tag_txt); tagView.setText(tag); tagView.setPadding(INNER_VIEW_PADDING, INNER_VIEW_PADDING, INNER_VIEW_PADDING, INNER_VIEW_PADDING); tagView.setTextColor(mTagTextColor); tagView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mSelectListener != null) { mSelectListener.onTagSelected(tag, position); } } }); // calculateof tag layout width float tagWidth = tagView.getPaint().measureText(tag) + INNER_VIEW_PADDING * 2; // tagView padding (left & right) // deletable text TextView deletableView = (TextView) tagLayout.findViewById(R.id.delete_txt); if (mIsDeletable) { deletableView.setVisibility(View.VISIBLE); deletableView.setText(DEFAULT_DELETABLE_STRING); deletableView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mDeleteListener != null) { String targetTag = tag; TagCloudLinkView.this.remove(position); mDeleteListener.onTagDeleted(targetTag, position); } } }); tagWidth += deletableView.getPaint().measureText(DEFAULT_DELETABLE_STRING) + INNER_VIEW_PADDING * 2; // deletableView Padding (left & right) } else { deletableView.setVisibility(View.GONE); } LayoutParams tagParams = new LayoutParams(HEIGHT_WC, HEIGHT_WC); tagParams.setMargins(0, 0, 0, 0); if (mWidth <= total + tagWidth + LAYOUT_WIDTH_OFFSET) { tagParams.addRule(RelativeLayout.BELOW, pindex); tagParams.topMargin = TAG_LAYOUT_TOP_MERGIN; // initialize total param (layout padding left & layout padding right) total = getPaddingLeft() + getPaddingRight(); pindex = index; } else { tagParams.addRule(RelativeLayout.ALIGN_TOP, pindex); tagParams.addRule(RelativeLayout.RIGHT_OF, index - 1); if (index > 1) { tagParams.leftMargin = TAG_LAYOUT_LEFT_MERGIN; total += TAG_LAYOUT_LEFT_MERGIN; } } total += tagWidth; addView(tagLayout, tagParams); index++; listIndex++; } LayoutParams tagParams = new LayoutParams(HEIGHT_WC, HEIGHT_WC); tagParams.setMargins(0, 0, 0, 0); if (isAutoCompleteMode || !mIsDeletable) { return; } int tagWidth = 50; //25dp if (mWidth <= total + tagWidth + LAYOUT_WIDTH_OFFSET) { tagParams.addRule(RelativeLayout.BELOW, pindex); tagParams.topMargin = TAG_LAYOUT_TOP_MERGIN; // initialize total param (layout padding left & layout padding right) total = getPaddingLeft() + getPaddingRight(); pindex = index; } else { tagParams.addRule(RelativeLayout.ALIGN_TOP, pindex); tagParams.addRule(RelativeLayout.RIGHT_OF, index - 1); if (index > 1) { tagParams.leftMargin = TAG_LAYOUT_LEFT_MERGIN; total += TAG_LAYOUT_LEFT_MERGIN; } } total += tagWidth; View tagLayout = (View) mInflater.inflate(R.layout.tag, null); addView(tagLayout, tagParams); tagLayout.findViewById(R.id.add_image_view).setVisibility(VISIBLE); tagLayout.findViewById(R.id.tag_txt).setVisibility(GONE); tagLayout.setClickable(true); tagLayout.setFocusable(true); tagLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (mAddTagListener != null) { mAddTagListener.onAddTag(); } } }); int transparentColor = ContextCompat.getColor(getContext(), android.R.color.transparent); tagLayout.setBackgroundColor(transparentColor); }