List of usage examples for android.widget RelativeLayout setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:me.ziccard.secureit.fragment.EmptyFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if ((savedInstanceState != null) && savedInstanceState.containsKey(CONTENT)) { mContent = savedInstanceState.getString(CONTENT); }/*from www. ja v a 2 s . c o m*/ TextView text = new TextView(getActivity()); text.setGravity(Gravity.CENTER); text.setText(mContent); text.setTextSize(20 * getResources().getDisplayMetrics().density); RelativeLayout layout = new RelativeLayout(getActivity()); layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); layout.setGravity(Gravity.CENTER); RelativeLayout alert = new RelativeLayout(getActivity()); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.leftMargin = 20; params.rightMargin = 20; params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_IN_PARENT); alert.setLayoutParams(params); alert.setBackgroundResource(R.drawable.red_back); alert.setPadding(30, 0, 30, 0); alert.addView(text); layout.addView(alert); return layout; }
From source file:com.eggsoftware.flingsolver.gui.DrawSolutionPageAdapter.java
@Override public Object instantiateItem(View collection, int position) { // Create the "Step N of T" TextView TextView stepTextView = new TextView(this.context); stepTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); stepTextView.setTextColor(Color.rgb(113, 113, 113)); stepTextView.setGravity(Gravity.CENTER); stepTextView.setText(String.format(this.context.getResources().getString(R.string.step_of), position + 1, this.solution.size())); // Create the boar with the current step of the solution BoardCanvas board = new BoardCanvas(this.context); board.setBoardRepresentation(this.solution.get(position).getBoard()); board.setArrow(this.solution.get(position).getRow(), this.solution.get(position).getCol(), this.solution.get(position).getDirection()); // Add the components to the layout LinearLayout layout = new LinearLayout(this.context); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(16, 20, 16, 16);/* w w w . j a va2s . c o m*/ RelativeLayout relativeLatout = new RelativeLayout(this.context); relativeLatout.setLayoutParams( new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); relativeLatout.addView(board); layout.addView(relativeLatout); layout.addView(stepTextView); ((ViewPager) collection).addView(layout, 0); return layout; }
From source file:net.pocketmagic.android.carousel.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //no keyboard unless requested by user getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // compute screen size and scaling Singleton.getInstance().InitGUIFrame(this); int padding = m_Inst.Scale(10); // create the interface : full screen container RelativeLayout panel = new RelativeLayout(this); panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); panel.setPadding(padding, padding, padding, padding); panel.setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { Color.WHITE, Color.GRAY })); setContentView(panel);/*from ww w.j a v a2 s . com*/ // copy images from assets to sdcard AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma1.png", "plasma1.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma2.png", "plasma2.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma3.png", "plasma3.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma4.png", "plasma4.png", false); //Create carousel view documents ArrayList<CarouselDataItem> Docus = new ArrayList<CarouselDataItem>(); for (int i = 0; i < 1000; i++) { CarouselDataItem docu; if (i % 4 == 0) docu = new CarouselDataItem("/mnt/sdcard/plasma1.png", 0, "First Image " + i); else if (i % 4 == 1) docu = new CarouselDataItem("/mnt/sdcard/plasma2.png", 0, "Second Image " + i); else if (i % 4 == 2) docu = new CarouselDataItem("/mnt/sdcard/plasma3.png", 0, "Third Image " + i); else docu = new CarouselDataItem("/mnt/sdcard/plasma4.png", 0, "4th Image " + i); Docus.add(docu); } // add the serach filter EditText etSearch = new EditText(this); etSearch.setHint("Search your documents"); etSearch.setSingleLine(); etSearch.setTextColor(Color.BLACK); etSearch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_menu_search, 0, 0, 0); AppUtils.AddView(panel, etSearch, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_TOP } }, -1, -1); etSearch.addTextChangedListener((TextWatcher) this); // add logo TextView tv = new TextView(this); tv.setTextColor(Color.BLACK); tv.setText("www.pocketmagic.net"); AppUtils.AddView(panel, tv, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_BOTTOM } }, -1, -1); // create the carousel CarouselView coverFlow = new CarouselView(this); // create adapter and specify device independent items size (scaling) // for more details see: http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/ m_carouselAdapter = new CarouselViewAdapter(this, Docus, m_Inst.Scale(400), m_Inst.Scale(300)); coverFlow.setAdapter(m_carouselAdapter); coverFlow.setSpacing(-1 * m_Inst.Scale(150)); coverFlow.setSelection(Integer.MAX_VALUE / 2, true); coverFlow.setAnimationDuration(1000); coverFlow.setOnItemSelectedListener((OnItemSelectedListener) this); AppUtils.AddView(panel, coverFlow, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_IN_PARENT } }, -1, -1); }
From source file:com.applivery.applvsdklib.ui.views.update.MustUpdateViewImpl.java
/** * Overrided in order to get fullScreen dialog * @param savedInstanceState/*ww w .j av a 2s.com*/ * @return */ @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final RelativeLayout root = new RelativeLayout(getActivity()); root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(root); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW)); dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); return dialog; }
From source file:com.mindorks.framework.mvp.ui.base.BaseDialog.java
@NonNull @Override//from w ww . ja v a 2 s .c o m public Dialog onCreateDialog(Bundle savedInstanceState) { // the content final RelativeLayout root = new RelativeLayout(getActivity()); root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // creating the fullscreen dialog final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(root); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } dialog.setCanceledOnTouchOutside(false); return dialog; }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Show the alert//w w w . j a v a 2s . co m * * @param context application-specific resources * @param configuration describes all device configuration information * @param text message to be displayed * @param forceClearPreviousAlert true will clear previous alert else keep it */ @SuppressLint("NewApi") private static void showAlertOnScreen(final Activity context, final Configuration configuration, final String text, boolean forceClearPreviousAlert) { final ViewGroup mainView = ((ViewGroup) context.findViewById(android.R.id.content)); boolean currentlyDisplayed = false; int viewId = R.id.alert_view_top; final TextView textView; boolean alertAlreadyExists = false; if (configuration.getOrientation().equals(Configuration.Orientation.BOTTOM)) { viewId = R.id.alert_view_bottom; } // Retrieving the view RelativeLayout relativeLayout = (RelativeLayout) mainView.findViewById(viewId); if (forceClearPreviousAlert) { mainView.removeView(relativeLayout); relativeLayout = null; } // Creating the view if (relativeLayout == null) { // Main layout relativeLayout = new RelativeLayout(context); relativeLayout.setId(viewId); relativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, configuration.getHeight())); relativeLayout.setGravity(Gravity.CENTER); // Textview textView = new TextView(context); textView.setId(R.id.alert_view_text); textView.setGravity(Gravity.CENTER); textView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); relativeLayout.addView(textView); setIcon(context, configuration, relativeLayout, textView); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { relativeLayout.setY(-configuration.getHeight()); } else { relativeLayout.setY(mainView.getHeight()); } // Adding the view to the global layout mainView.addView(relativeLayout, 0); relativeLayout.bringToFront(); relativeLayout.requestLayout(); relativeLayout.invalidate(); } // View already exists else { alertAlreadyExists = true; textView = (TextView) relativeLayout.findViewById(R.id.alert_view_text); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { if (relativeLayout.getY() == 0) { currentlyDisplayed = true; } } else { if (relativeLayout.getY() < mainView.getHeight()) { currentlyDisplayed = true; } } // The view is currently shown to the user if (currentlyDisplayed) { // If the message is not the same, we hide the current message and display the new one if (!StringUtils.equals(text, textView.getText())) { // Anim out the current message ViewPropertyAnimator viewPropertyAnimator = animOut(configuration, mainView, relativeLayout); final RelativeLayout relativeLayoutFinal = relativeLayout; if (viewPropertyAnimator != null) { // Anim in the new message after the animation out has finished if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { viewPropertyAnimator.setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } else { viewPropertyAnimator.withEndAction(new Runnable() { @Override public void run() { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } } else { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } } } } final RelativeLayout relativeLayoutFinal = relativeLayout; // Close the alert by clicking the layout if (configuration.isCloseable()) { relativeLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { animOut(configuration, mainView, relativeLayoutFinal); v.performClick(); return true; } }); } if (!currentlyDisplayed) { // Set the icon in case the alert already exists but it's not currently displayed if (alertAlreadyExists) { setIcon(context, configuration, relativeLayoutFinal, textView); } // We anim in the alert animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }
From source file:com.adobe.plugins.FastCanvas.java
public void initView() { Log.i("CANVAS", "FastCanvas initView"); mActivity.runOnUiThread(new Runnable() { @Override/* w w w . j a v a 2 s. c om*/ public void run() { final RelativeLayout top = new RelativeLayout(mActivity); top.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); top.addView(mCanvasView); mActivity.setContentView(top); } // end run }); // end runnable }
From source file:com.mllrsohn.videodialog.VideoDialogPlugin.java
private void playVideo(JSONObject params, final CallbackContext callbackContext) throws JSONException { loopVideo = params.optBoolean("loop", true); path = params.optString("url"); uri = Uri.parse(path);/*from ww w. j ava 2 s .c o m*/ if (path.contains(ASSETS)) { try { String filepath = path.replace(ASSETS, ""); String filename = filepath.substring(filepath.lastIndexOf("/") + 1, filepath.length()); File fp = new File(this.cordova.getActivity().getFilesDir() + "/" + filename); if (!fp.exists()) { this.copy(filepath, filename); } uri = Uri.parse("file://" + this.cordova.getActivity().getFilesDir() + "/" + filename); } catch (IOException e) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.IO_EXCEPTION)); } } // Create dialog in new thread cordova.getActivity().runOnUiThread(new Runnable() { public void run() { // Set Basic Dialog dialog = new Dialog((Context) cordova.getActivity(), android.R.style.Theme_NoTitleBar_Fullscreen); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); // Layout View RelativeLayout main = new RelativeLayout((Context) cordova.getActivity()); main.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // Video View mVideoView = new VideoView((Context) cordova.getActivity()); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_IN_PARENT); mVideoView.setLayoutParams(lp); mVideoView.setVideoPath(uri.toString()); mVideoView.start(); main.addView(mVideoView); dialog.setContentView(main); dialog.getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN); dialog.show(); // Close on touch mVideoView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "stopped")); dialog.dismiss(); return true; } }); // Set Looping mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.setLooping(loopVideo); } }); // On Completion mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaplayer) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, "Done")); dialog.dismiss(); } }); } }); }
From source file:de.gebatzens.ggvertretungsplan.fragment.RemoteDataFragment.java
public void createButtonWithText(Activity activity, ViewGroup l, String text, String button, View.OnClickListener onclick) { RelativeLayout r = new RelativeLayout(activity); r.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); TextView tv = new TextView(activity); RelativeLayout.LayoutParams tvparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); tvparams.addRule(RelativeLayout.ABOVE, R.id.reload_button); tvparams.addRule(RelativeLayout.CENTER_HORIZONTAL); tv.setLayoutParams(tvparams);/*from ww w.j a v a 2 s . c o m*/ tv.setText(text); tv.setTextSize(23); tv.setPadding(0, 0, 0, toPixels(15)); tv.setGravity(Gravity.CENTER_HORIZONTAL); r.addView(tv); Button b = new Button(activity); RelativeLayout.LayoutParams bparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); bparams.addRule(RelativeLayout.CENTER_VERTICAL); bparams.addRule(RelativeLayout.CENTER_HORIZONTAL); b.setLayoutParams(bparams); b.setId(R.id.reload_button); b.setText(button); b.setTextSize(23); b.setAllCaps(false); b.setTypeface(null, Typeface.NORMAL); b.setOnClickListener(onclick); r.addView(b); l.addView(r); }
From source file:r2b.apps.view.base.BaseAbsListFragment.java
@Override protected void initViews() { absListView = (AbsListView) getView().findViewById(android.R.id.list); emptyView = getEmptyView();//from ww w.j av a 2 s. c om errorView = getErrorView(); loadingView = getLoadingView(); RelativeLayout.LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.CENTER_HORIZONTAL); lp.addRule(RelativeLayout.CENTER_VERTICAL); RelativeLayout rl = new RelativeLayout(getActivity()); rl.setLayoutParams(lp); if (emptyView != null) { rl.addView(emptyView); } if (errorView != null) { rl.addView(errorView); } if (loadingView != null) { rl.addView(loadingView); } ViewGroup parent = (ViewGroup) absListView.getParent(); parent.addView(rl); absListView.setEmptyView(rl); showEmptyView(); }