List of usage examples for android.widget RelativeLayout ALIGN_PARENT_RIGHT
int ALIGN_PARENT_RIGHT
To view the source code for android.widget RelativeLayout ALIGN_PARENT_RIGHT.
Click Source Link
From source file:com.cloudexplorers.plugins.childBrowser.ChildBrowser.java
/** * Display a new browser with the specified URL. * /*from www. j av a 2 s. co m*/ * @param url * The url to load. * @param jsonObject */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", true); } // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button ImageButton back = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); try { back.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button ImageButton forward = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); try { forward.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... // Makes the text // NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button ImageButton close = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); try { close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView webview = new WebView(cordova.getActivity()); webview.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); webview.setWebChromeClient(new WebChromeClient()); WebViewClient client = new ChildBrowserClient(edittext); webview.setWebViewClient(client); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); webview.loadUrl(url); webview.setId(6); webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setUseWideViewPort(true); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setPluginsEnabled(true); webview.requestFocus(); webview.requestFocusFromTouch(); // Add the back and forward buttons to our action button container // layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(webview); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = cordova.getActivity().getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:xyz.berial.textinputlayout.TextInputLayout.java
/** * //from w w w . java2 s .c om * * @param enabled ? */ public void setCounterEnabled(boolean enabled) { if (mCounterEnabled != enabled) { if (enabled) { mCounterView = new TextView(getContext()); // mCounterView.setVisibility(VISIBLE); if (mEditText != null && mEditText.length() > mCounterMaxLength) { mCounterView.setTextAppearance(getContext(), mErrorTextAppearance); } else { mCounterView.setTextAppearance(getContext(), R.style.TextAppearance_Design_Counter); } RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.CENTER_VERTICAL); mBottomBar.addView(mCounterView, params); if (mEditText != null) { // Add some start/end padding to the counter so that it matches the EditText ViewCompat.setPaddingRelative(mCounterView, ViewCompat.getPaddingStart(mEditText), 0, ViewCompat.getPaddingEnd(mEditText), mEditText.getPaddingBottom()); } mCounterView.setText(mResources.getString(R.string.counterMaxLength, 0, mCounterMaxLength)); } else { mBottomBar.removeView(mCounterView); mCounterView = null; } mCounterEnabled = enabled; } }
From source file:org.protocoderrunner.apprunner.AppRunnerFragment.java
public RelativeLayout initLayout() { LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); // add main layout mainLayout = new RelativeLayout(mActivity); mainLayout.setLayoutParams(layoutParams); mainLayout.setGravity(Gravity.BOTTOM); // mainLayout.setBackgroundColor(getResources().getColor(R.color.transparent)); mainLayout.setBackgroundColor(getResources().getColor(R.color.white)); // set the parent parentScriptedLayout = new RelativeLayout(mActivity); parentScriptedLayout.setLayoutParams(layoutParams); parentScriptedLayout.setGravity(Gravity.BOTTOM); parentScriptedLayout.setBackgroundColor(getResources().getColor(R.color.transparent)); mainLayout.addView(parentScriptedLayout); // editor layout editorLayout = new FrameLayout(mActivity); FrameLayout.LayoutParams editorParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);/*from w w w. j a va 2 s . co m*/ editorLayout.setLayoutParams(editorParams); editorLayout.setId(EDITOR_ID); mainLayout.addView(editorLayout); // console layout consoleRLayout = new RelativeLayout(mActivity); RelativeLayout.LayoutParams consoleLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, getResources().getDimensionPixelSize(R.dimen.apprunner_console)); consoleLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); consoleLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); consoleRLayout.setLayoutParams(consoleLayoutParams); consoleRLayout.setGravity(Gravity.BOTTOM); consoleRLayout.setBackgroundColor(getResources().getColor(R.color.blacktransparent)); consoleRLayout.setVisibility(View.GONE); mainLayout.addView(consoleRLayout); // Create the text view to add to the console layout consoleText = new TextView(mActivity); LayoutParams consoleTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); consoleText.setBackgroundColor(getResources().getColor(R.color.transparent)); consoleText.setTextColor(getResources().getColor(R.color.white)); consoleText.setLayoutParams(consoleTextParams); int textPadding = getResources().getDimensionPixelSize(R.dimen.apprunner_console_text_padding); consoleText.setPadding(textPadding, textPadding, textPadding, textPadding); consoleRLayout.addView(consoleText); //add a close button Button closeBtn = new Button(mActivity); closeBtn.setText("x"); closeBtn.setPadding(5, 5, 5, 5); closeBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showConsole(false); } }); RelativeLayout.LayoutParams closeBtnLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); closeBtnLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); closeBtnLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); closeBtn.setLayoutParams(closeBtnLayoutParams); consoleRLayout.addView(closeBtn); liveCoding = new PLiveCodingFeedback(mActivity); mainLayout.addView(liveCoding.add()); return mainLayout; }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Set the icon on the alert/* w w w . java 2s . com*/ * * @param context application-specific resources * @param configuration describes all device configuration information * @param mainView ViewGroup resources * @param textView alert message to be viewed message to be displayedView */ @SuppressLint("NewApi") private static void setIcon(Activity context, Configuration configuration, ViewGroup mainView, TextView textView) { ImageView imageView = (ImageView) mainView.findViewById(R.id.alert_view_icon); // Reset the current icon if (imageView != null) { mainView.removeView(imageView); } // On the textview as well textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); textView.setCompoundDrawablePadding(0); if (configuration.getIconResId() != -1) { imageView = new ImageView(context); imageView.setId(R.id.alert_view_icon); imageView.setImageResource(configuration.getIconResId()); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageView.setLayoutParams(layoutParams); switch (configuration.getIconPosition()) { case LEFT_TEXT: textView.setCompoundDrawablesWithIntrinsicBounds(configuration.getIconResId(), 0, 0, 0); textView.setCompoundDrawablePadding(10); break; case RIGHT_TEXT: textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, configuration.getIconResId(), 0); textView.setCompoundDrawablePadding(10); break; case LEFT: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START); } layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layoutParams.setMargins(25, 0, 0, 0); mainView.addView(imageView); // We redefine the layout params otherwise the image is not well aligned textView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); break; case RIGHT: default: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { layoutParams.addRule(RelativeLayout.ALIGN_PARENT_END); } layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layoutParams.setMargins(0, 0, 25, 0); mainView.addView(imageView); // We redefine the layout params otherwise the image is not well aligned textView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); break; } } }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Creates the clear image cache button, add listener for clear image cache. * @return the relative layout// w w w. ja va 2 s . c o m */ private RelativeLayout createClearImageCacheButton() { RelativeLayout clearImageView = new RelativeLayout(this); clearImageView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); Button clearImgCacheBtn = new Button(this); clearImgCacheBtn.setText("Clear Image Cache"); RelativeLayout.LayoutParams clearButtonLayout = new RelativeLayout.LayoutParams(150, LayoutParams.WRAP_CONTENT); clearButtonLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); clearImgCacheBtn.setLayoutParams(clearButtonLayout); clearImgCacheBtn.setOnClickListener(new OnClickListener() { public void onClick(View v) { ViewHelper.showAlertViewWithTitleYesOrNo(AppSettingsActivity.this, "", "Are you sure you want to clear image cache?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { FileUtil.clearImagesInCache(AppSettingsActivity.this); } }); } }); clearImageView.addView(clearImgCacheBtn); return clearImageView; }
From source file:freed.cam.ui.themesample.cameraui.CameraUiFragment.java
@Override public void onSettingsChildClick(UiSettingsChild item, boolean fromLeftFragment) { if (currentOpendChild == item) { removeHorizontalFragment();/* w ww. j a v a2 s . c o m*/ currentOpendChild = null; return; } if (currentOpendChild != null) { removeHorizontalFragment(); currentOpendChild = null; } if (horizontalValuesFragment != null) horizontalValuesFragment.Clear(); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.leftMargin = getResources().getDimensionPixelSize(dimen.manualitemwidth); params.rightMargin = getResources().getDimensionPixelSize(dimen.shuttericon_size); //params.addRule(RelativeLayout.CENTER_VERTICAL); if (manualsettingsIsOpen) params.bottomMargin = getResources().getDimensionPixelSize(dimen.manualSettingsHeight); if (fromLeftFragment) params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); else params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); camerauiValuesFragmentHolder.setLayoutParams(params); currentOpendChild = item; horizontalValuesFragment = new HorizontalValuesFragment(); String[] tmo = item.GetValues(); if (tmo != null && tmo.length > 0) horizontalValuesFragment.SetStringValues(tmo, this); else horizontalValuesFragment.ListenToParameter(item.GetParameter()); infalteIntoHolder(id.cameraui_values_fragment_holder, horizontalValuesFragment); }
From source file:com.cranberrygame.phonegap.plugin.ad.Util.java
private void _showBannerAd(String position, String size) { this.position = position; this.size = size; if (bannerAdPreloaded) { bannerAdPreloaded = false;/* w w w . j a va 2s. c o m*/ } else { _preloadBannerAd(); } //http://tigerwoods.tistory.com/11 //http://developer.android.com/reference/android/widget/RelativeLayout.html //http://stackoverflow.com/questions/24900725/admob-banner-poitioning-in-android-on-bottom-of-the-screen-using-no-xml-relative RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(AdView.LayoutParams.WRAP_CONTENT, AdView.LayoutParams.WRAP_CONTENT); if (position.equals("top-left")) { Log.d("Admob", "top-left"); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); } else if (position.equals("top-center")) { params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } else if (position.equals("top-right")) { params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else if (position.equals("left")) { params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.CENTER_VERTICAL); } else if (position.equals("center")) { params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); } else if (position.equals("right")) { params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.CENTER_VERTICAL); } else if (position.equals("bottom-left")) { params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); } else if (position.equals("bottom-center")) { params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } else if (position.equals("bottom-right")) { params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else { params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.CENTER_HORIZONTAL); } //bannerViewLayout.addView(bannerView, params); bannerView.setLayoutParams(params); bannerViewLayout.addView(bannerView); }
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;//from w w w . j av a 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); }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Creates the auto layout./*from ww w.j a va 2 s . c o m*/ * It contains toggle button to switch auto state, two text view to indicate auto messages. * * @return the relative layout */ private RelativeLayout createAutoLayout() { RelativeLayout autoLayout = new RelativeLayout(this); autoLayout.setPadding(10, 5, 10, 10); autoLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 80)); TextView autoText = new TextView(this); RelativeLayout.LayoutParams autoTextLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); autoTextLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); autoTextLayout.addRule(RelativeLayout.CENTER_VERTICAL); autoText.setLayoutParams(autoTextLayout); autoText.setText("Auto Discovery"); ToggleButton autoButton = new ToggleButton(this); autoButton.setWidth(150); RelativeLayout.LayoutParams autoButtonLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); autoButtonLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); autoButtonLayout.addRule(RelativeLayout.CENTER_VERTICAL); autoButton.setLayoutParams(autoButtonLayout); autoButton.setChecked(autoMode); autoButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { appSettingsView.removeViewAt(2); currentServer = ""; if (isChecked) { IPAutoDiscoveryServer.isInterrupted = false; appSettingsView.addView(constructAutoServersView(), 2); } else { IPAutoDiscoveryServer.isInterrupted = true; appSettingsView.addView(constructCustomServersView(), 2); } AppSettingsModel.setAutoMode(AppSettingsActivity.this, isChecked); } }); TextView infoText = new TextView(this); RelativeLayout.LayoutParams infoTextLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); infoTextLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); infoTextLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); infoText.setLayoutParams(infoTextLayout); infoText.setTextSize(10); infoText.setText("Turn off auto-discovery to input controller url manually."); autoLayout.addView(autoText); autoLayout.addView(autoButton); autoLayout.addView(infoText); return autoLayout; }
From source file:com.uzmap.pkg.uzmodules.UISearchBar.SearchBarActivity.java
@SuppressWarnings("deprecation") private void initData() { DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metric); mPref = getSharedPreferences("text", Context.MODE_PRIVATE); String text = mPref.getString("text", ""); if (!TextUtils.isEmpty(text)) { mEditText.setText(text);/* w w w . j av a 2 s . c o m*/ mEditText.setSelection(text.length()); } mNavigationLayout.setBackgroundColor(config.navBgColor); if (TextUtils.isEmpty(config.searchBoxBgImg)) { BitmapDrawable bitmapDrawable = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), UZResourcesIDFinder.getResDrawableID("mo_searchbar_bg"))); mRelativeLayout.setBackgroundDrawable(bitmapDrawable); } else { BitmapDrawable bitmapDrawable = new BitmapDrawable(generateBitmap(config.searchBoxBgImg)); mRelativeLayout.setBackgroundDrawable(bitmapDrawable); } if (config.cancel_bg_bitmap != null) { mTextView.setBackgroundDrawable(new BitmapDrawable(config.cancel_bg_bitmap)); } else { mTextView.setBackgroundColor(config.cancel_bg_color); } mTextView.setTextSize(config.cancel_size); mTextView.setTextColor(config.cancal_color); LayoutParams params = new LayoutParams(UZUtility.dipToPix(config.searchBoxWidth), UZUtility.dipToPix(config.searchBoxHeight)); params.setMargins(UZUtility.dipToPix(10), 0, 0, 0); params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mEditText.setLayoutParams(params); WindowManager wm = this.getWindowManager(); int width = wm.getDefaultDisplay().getWidth(); double realWidth = width * 0.80; LayoutParams layoutParams = new LayoutParams((int) realWidth, UZUtility.dipToPix(config.searchBoxHeight)); layoutParams.setMargins(UZUtility.dipToPix(5), 0, 0, 0); layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); layoutParams.topMargin = UZUtility.dipToPix(8); layoutParams.bottomMargin = UZUtility.dipToPix(8); mRelativeLayout.setLayoutParams(layoutParams); double cancelRealWidth = width * 0.15; int space = (width - (int) realWidth - (int) cancelRealWidth - UZUtility.dipToPix(5)) / 2; LayoutParams cancalTxtParam = new LayoutParams((int) cancelRealWidth, UZUtility.dipToPix(config.searchBoxHeight)); cancalTxtParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); cancalTxtParam.addRule(RelativeLayout.CENTER_VERTICAL); cancalTxtParam.rightMargin = space; cancalTxtParam.leftMargin = space; mTextView.setLayoutParams(cancalTxtParam); mListView.setBackgroundColor(config.list_bg_color); listSize = config.list_size; mCleanTextColor = config.clear_font_color; mCleanTextSize = config.clear_font_size; recordCount = config.historyCount; /** * add clean list item */ int relativeLayoutCleanId = UZResourcesIDFinder.getResLayoutID("mo_searchbar_clean_item"); relativeLayoutClean = (LinearLayout) View.inflate(getApplicationContext(), relativeLayoutCleanId, null); int tv_cleanId = UZResourcesIDFinder.getResIdID("tv_clean"); mCleanTV = (TextView) relativeLayoutClean.findViewById(tv_cleanId); mCleanTV.setTextSize(mCleanTextSize); mCleanTV.setTextColor(mCleanTextColor); mCleanTV.setText(config.clearText); relativeLayoutClean .setBackgroundDrawable(addStateDrawable(config.clear_bg_color, config.clear_active_bg_color)); list.clear(); list.add(relativeLayoutClean); mPref = getSharedPreferences("history" + config.database, Context.MODE_PRIVATE); editor = mPref.edit(); trimHistroyList(config.historyCount); @SuppressWarnings("unchecked") Map<String, String> map = (Map<String, String>) mPref.getAll(); if (map != null) { if (map.size() != 0) { for (int i = 1; i <= map.size(); i++) { int listview_item = UZResourcesIDFinder.getResLayoutID("mo_searchbar_listview_item"); LinearLayout linearLayout = (LinearLayout) View.inflate(SearchBarActivity.this, listview_item, null); int tv_listId = UZResourcesIDFinder.getResIdID("tv_listview"); TextView tv = (TextView) linearLayout.findViewById(tv_listId); tv.setTextSize(listSize); tv.setTextColor(config.list_color); linearLayout.setBackgroundDrawable( addStateDrawable(config.list_bg_color, config.list_item_active_bg_color)); int itemBorderLineId = UZResourcesIDFinder.getResIdID("item_border_line"); linearLayout.findViewById(itemBorderLineId).setBackgroundColor(config.list_border_color); for (Entry<String, String> iterable_element : map.entrySet()) { String key = iterable_element.getKey(); if ((i + "").equals(key)) { tv.setText(iterable_element.getValue()); } } list.addFirst(linearLayout); } id = map.size(); } } adapter = new MyAdapter(); mListView.setAdapter(adapter); }