List of usage examples for android.widget RelativeLayout getChildAt
public View getChildAt(int index)
From source file:com.yibairun.ui.components.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { RelativeLayout tabLayout = (RelativeLayout) tabsContainer.getChildAt(i); View v = tabLayout.getChildAt(0); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); }//from www . j av a 2s .c om } if (i == selectedPosition) { tab.setTextColor(selectedTabTextColor); } } } }
From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java
private void removeOutOfBoundsAnnotations() { RelativeLayout relativeLayout = (RelativeLayout) findViewById( R.id.supersede_feedbacklibrary_annotate_image_layout); if (relativeLayout != null) { List<View> toRemove = new ArrayList<>(); int newBitmapWidth = annotateImageView.getBitmapWidth(); int newBitmapHeight = annotateImageView.getBitmapHeight(); float fraction = 0.5f; for (int i = 0; i < relativeLayout.getChildCount(); ++i) { View child = relativeLayout.getChildAt(i); if (child instanceof StickerAnnotationView || child instanceof TextAnnotationView) { // A fraction the sticker should be visible, if not the sticker will be removed float deleteThresholdX = child.getWidth() * fraction; float deleteThresholdY = child.getHeight() * fraction; float x = child.getX(); float y = child.getY(); boolean xOk = true; boolean yOk = true; if (x < 0) { xOk = Math.abs(x) < deleteThresholdX; } else if (x > 0 && !(x < 0)) { xOk = x + deleteThresholdX < newBitmapWidth; }//from www . ja va 2s . c om if (y < 0) { yOk = Math.abs(y) < deleteThresholdY; } else if (y > 0 && !(y < 0)) { yOk = y + deleteThresholdY < newBitmapHeight; } if (!(xOk && yOk)) { toRemove.add(child); } } } for (int i = 0; i < toRemove.size(); ++i) { relativeLayout.removeView(toRemove.get(i)); } toRemove.clear(); textAnnotationCounter = 1; for (int i = 0; i < relativeLayout.getChildCount(); ++i) { View child = relativeLayout.getChildAt(i); if (child instanceof TextAnnotationView) { String newAnnotationNumber = Integer.toString(textAnnotationCounter); ((TextAnnotationImageView) child).getAnnotationNumberView().setText(newAnnotationNumber); textAnnotationCounter++; } if (textAnnotationCounter > textAnnotationCounterMaximum) { break; } } } }
From source file:com.arkami.myidkey.activity.KeyCardEditActivity.java
/** * Sets screen components edit mode/*from w w w . ja va 2 s . c o m*/ * * @param editable if the components are editable or not. */ private void setEditable(boolean editable) { this.keyCardName.setEnabled(editable); this.favourite.setEnabled(editable); if (editable) { this.tagSpinner.setVisibility(View.VISIBLE); } else { this.tagSpinner.setVisibility(View.INVISIBLE); } for (int i = 0; i < this.photosLinearLayout.getChildCount(); i++) { RelativeLayout photoLayout = (RelativeLayout) this.photosLinearLayout.getChildAt(i); if (editable) { photoLayout.getChildAt(1).setVisibility(View.VISIBLE); } else { photoLayout.getChildAt(1).setVisibility(View.GONE); } } for (int i = 0; i < this.audioLinearLayout.getChildCount(); i++) { RelativeLayout audioLayout = (RelativeLayout) this.audioLinearLayout.getChildAt(i); if (editable) { audioLayout.getChildAt(1).setVisibility(View.VISIBLE); } else { audioLayout.getChildAt(1).setVisibility(View.GONE); } } for (int i = 0; i < this.selectedTags.getChildCount(); i++) { LinearLayout tag = (LinearLayout) this.selectedTags.getChildAt(i); RelativeLayout tagLayout = (RelativeLayout) tag.getChildAt(0); if (editable) { tagLayout.getChildAt(1).setVisibility(View.VISIBLE); } else { tagLayout.getChildAt(1).setVisibility(View.GONE); } } for (CustomViewComponent component : this.componentHolder.getCustomComponents()) { component.setEditable(editable); } }
From source file:com.www.avtovokzal.org.MainActivity.java
private void listViewListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*w w w. ja v a2s .c om*/ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String name; String numberToView; RelativeLayout rl = (RelativeLayout) view; TextView textViewTime = (TextView) rl.getChildAt(0); TextView textViewNumber = (TextView) rl.getChildAt(1); TextView textViewName = (TextView) rl.getChildAt(2); time = textViewTime.getText().toString(); number = textViewNumber.getTag().toString(); numberToView = textViewNumber.getText().toString(); name = textViewName.getText().toString(); Intent intent = new Intent(getApplicationContext(), InfoActivity.class); intent.putExtra("number", number); intent.putExtra("numberToView", numberToView); intent.putExtra("time", time); intent.putExtra("name", name); intent.putExtra("day", day); startActivity(intent); } }); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int def = totalItemCount - (firstVisibleItem + visibleItemCount); if (totalItemCount > 0 && def < 3 && fab.getVisibility() == View.VISIBLE) { Animation fadeOutAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out); fab.setAnimation(fadeOutAnimation); fab.setVisibility(View.GONE); } else if (totalItemCount > 0 && def > 3 && fab.getVisibility() != View.VISIBLE) { Animation fadeInAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in); fab.setAnimation(fadeInAnimation); fab.setVisibility(View.VISIBLE); } } }); }
From source file:com.www.avtovokzal.org.MainActivity.java
private void myAutoCompleteListener() { myAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w ww .j a v a2s .c o m public void onItemClick(AdapterView<?> parent, View agr1, int pos, long id) { RelativeLayout rl = (RelativeLayout) agr1; TextView tv = (TextView) rl.getChildAt(0); nameStation = tv.getText().toString(); myAutoComplete.setText(nameStation); // ? InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Activity.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(myAutoComplete.getWindowToken(), 0); code = tv.getTag().toString(); // ? ? loadScheduleResult(code, day, cancel, sell, all); myAutoComplete.clearFocus(); if (Integer.parseInt(code) == 102 && showDialogKoltsovo) { FragmentManager manager = getSupportFragmentManager(); KoltsovoDialogFragment dialogFragment = new KoltsovoDialogFragment(); dialogFragment.show(manager, "dialog"); } } }); myAutoComplete.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { int count = myAdapter.getCount(); if (count > 0) { AutoCompleteObject object = myAdapter.getItem(0); myAutoComplete.setText(object.toString()); code = object.getObjectCode(); // ? InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Activity.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(myAutoComplete.getWindowToken(), 0); // ? ? loadScheduleResult(code, day, cancel, sell, all); myAutoComplete.clearFocus(); if (Integer.parseInt(code) == 102 && showDialogKoltsovo) { FragmentManager manager = getSupportFragmentManager(); KoltsovoDialogFragment dialogFragment = new KoltsovoDialogFragment(); dialogFragment.show(manager, "dialog"); } } } return false; } }); }
From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java
private RelativeLayout createParticipantView(MemberStatusTO ms) { RelativeLayout rl = new RelativeLayout(this); int rlW = UIUtils.convertDipToPixels(this, 55); rl.setLayoutParams(new RelativeLayout.LayoutParams(rlW, rlW)); getLayoutInflater().inflate(R.layout.avatar, rl); ImageView avatar = (ImageView) rl.getChildAt(rl.getChildCount() - 1); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(avatar.getLayoutParams()); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); avatar.setLayoutParams(params);//from w w w .j a v a 2 s .c o m setAvatar(avatar, ms.member); ImageView statusView = new ImageView(this); int w = UIUtils.convertDipToPixels(this, 12); RelativeLayout.LayoutParams iconParams = new RelativeLayout.LayoutParams(w, w); iconParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); iconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE); statusView.setLayoutParams(iconParams); statusView.setAdjustViewBounds(true); statusView.setScaleType(ScaleType.CENTER_CROP); setStatusIcon(statusView, ms); rl.addView(statusView); return rl; }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public void highlightbutton(View arg0) { try {// w ww. jav a2 s.co m RelativeLayout parent = ((RelativeLayout) arg0.getParent()); for (int child = 0; child < parent.getChildCount(); child++) { parent.getChildAt(child).setBackgroundColor(Color.TRANSPARENT); } } catch (Throwable e) { LinearLayout parent = ((LinearLayout) arg0.getParent()); for (int child = 0; child < parent.getChildCount(); child++) { parent.getChildAt(child).setBackgroundColor(Color.TRANSPARENT); } } arg0.setBackgroundColor(Color.parseColor("#501BADA9")); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
@Override public void onGUICreate() { this.clearViews(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()); // change shutter icon isRecording = false;// w w w. j a va 2 s. c o m prefs.edit().putBoolean("videorecording", false).commit(); ApplicationScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START); onPreferenceCreate((PreferenceFragment) null); setupVideoSize(prefs); List<View> specialView = new ArrayList<View>(); RelativeLayout specialLayout = (RelativeLayout) ApplicationScreen.instance .findViewById(R.id.specialPluginsLayout2); for (int i = 0; i < specialLayout.getChildCount(); i++) specialView.add(specialLayout.getChildAt(i)); for (int j = 0; j < specialView.size(); j++) { View view = specialView.get(j); int view_id = view.getId(); if (view_id == this.mRecordingTimeView.getId() || view_id == this.modeSwitcher.getId()) { if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view); specialLayout.removeView(view); } } { final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3)) .removeView(this.modeSwitcher); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3)) .addView(this.modeSwitcher, params); this.modeSwitcher.setLayoutParams(params); } // Calculate right sizes for plugin's controls DisplayMetrics metrics = new DisplayMetrics(); ApplicationScreen.instance.getWindowManager().getDefaultDisplay().getMetrics(metrics); float fScreenDensity = metrics.density; int iIndicatorSize = (int) (ApplicationScreen.getMainContext().getResources() .getInteger(R.integer.infoControlHeight) * fScreenDensity); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(iIndicatorSize, iIndicatorSize); int topMargin = ApplicationScreen.instance.findViewById(R.id.paramsLayout).getHeight() + (int) ApplicationScreen.getAppResources().getDimension(R.dimen.viewfinderViewsMarginTop); params.setMargins((int) (2 * ApplicationScreen.getGUIManager().getScreenDensity()), topMargin, 0, 0); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout2)) .addView(this.mRecordingTimeView, params); this.mRecordingTimeView.setLayoutParams(params); LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater(); buttonsLayout = inflator.inflate(R.layout.plugin_capture_video_layout, null, false); buttonsLayout.setVisibility(View.VISIBLE); timeLapseButton = (RotateImageView) buttonsLayout.findViewById(R.id.buttonTimeLapse); pauseVideoButton = (RotateImageView) ApplicationScreen.instance.findViewById(R.id.buttonVideoPause); stopVideoButton = (RotateImageView) ApplicationScreen.instance.findViewById(R.id.buttonVideoStop); snapshotSupported = CameraController.isVideoSnapshotSupported(); takePictureButton = (RotateImageView) buttonsLayout.findViewById(R.id.buttonCaptureImage); timeLapseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TimeLapseDialog(); } }); pauseVideoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pauseVideoRecording(); } }); stopVideoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onShutterClick(); } }); if (snapshotSupported) { takePictureButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { takePicture(); } }); } for (int j = 0; j < specialView.size(); j++) { View view = specialView.get(j); int view_id = view.getId(); if (view_id == this.buttonsLayout.getId()) { if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view); specialLayout.removeView(view); } } params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.videobuttons_size); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout2)) .addView(this.buttonsLayout, params); this.buttonsLayout.setLayoutParams(params); if (snapshotSupported) { takePictureButton.setOrientation(ApplicationScreen.getGUIManager().getLayoutOrientation()); takePictureButton.invalidate(); // takePictureButton.requestLayout(); displayTakePicture = true; } else { takePictureButton.setVisibility(View.GONE); displayTakePicture = false; } timeLapseButton.setOrientation(ApplicationScreen.getGUIManager().getLayoutOrientation()); if (this.modeDRO() || CameraController.isRemoteCamera()) { takePictureButton.setVisibility(View.GONE); timeLapseButton.setVisibility(View.GONE); } if (prefs.getBoolean("videoStartStandardPref", false)) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: PluginManager.getInstance().onPause(true); Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); ApplicationScreen.instance.startActivity(intent); break; case DialogInterface.BUTTON_NEGATIVE: // No button clicked break; default: break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ApplicationScreen.instance); builder.setMessage("You selected to start standard camera. Start camera?") .setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener) .show(); } rotatorLayout = inflator.inflate(R.layout.plugin_capture_video_lanscaperotate_layout, null, false); rotatorLayout.setVisibility(View.VISIBLE); initRotateNotification(videoOrientation); List<View> specialViewRotator = new ArrayList<View>(); RelativeLayout specialLayoutRotator = (RelativeLayout) ApplicationScreen.instance .findViewById(R.id.specialPluginsLayout); for (int i = 0; i < specialLayoutRotator.getChildCount(); i++) specialViewRotator.add(specialLayoutRotator.getChildAt(i)); for (int j = 0; j < specialViewRotator.size(); j++) { View view = specialViewRotator.get(j); int view_id = view.getId(); int layout_id = this.rotatorLayout.getId(); if (view_id == layout_id) { if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view); specialLayoutRotator.removeView(view); } } RelativeLayout.LayoutParams paramsRotator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsRotator.height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.gui_element_2size); paramsRotator.addRule(RelativeLayout.CENTER_IN_PARENT); ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout)) .addView(this.rotatorLayout, paramsRotator); }