List of usage examples for android.widget LinearLayout setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.matthewmitchell.wakeifyplus.MinutesSecondsFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { TableRow.LayoutParams twoLP = new TableRow.LayoutParams(0, 0, 0.2f); TableRow.LayoutParams threeLP = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT, 0.3f); View spacer = new View(activity); spacer.setLayoutParams(twoLP);//from w ww .ja v a 2s . c om spacer.setVisibility(View.INVISIBLE); final NumberPicker minutes = new NumberPicker(activity); minutes.setMaxValue(30); minutes.setMinValue(0); minutes.setValue(defaultMinute); minutes.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); LinearLayout minutesLayout = new LinearLayout(activity); minutesLayout.addView(minutes); minutesLayout.setGravity(Gravity.CENTER); minutesLayout.setLayoutParams(threeLP); final NumberPicker seconds = new NumberPicker(activity); seconds.setMaxValue(59); seconds.setMinValue(0); seconds.setValue(defaultSecond); seconds.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS); LinearLayout secondsLayout = new LinearLayout(activity); secondsLayout.addView(seconds); secondsLayout.setGravity(Gravity.CENTER); secondsLayout.setLayoutParams(threeLP); LinearLayout layout = new LinearLayout(activity); layout.addView(spacer); layout.addView(minutesLayout); layout.addView(secondsLayout); layout.setWeightSum(1.0f); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("Set Volume Ramping Time").setView(layout) .setPositiveButton("Set", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.rampingMinutes = minutes.getValue(); activity.rampingSeconds = seconds.getValue(); TextView edit = (TextView) activity.findViewById(R.id.volume_ramping); edit.setText(activity.rampingMinutes + "m" + activity.rampingSeconds + "s"); } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Do nothing. } }); // Create the AlertDialog object and return it return builder.create(); }
From source file:org.nuxeo.android.layout.LayoutDefinition.java
protected ViewGroup createTopLayoutContainer(Context ctx, ViewGroup parent) { LinearLayout container = new LinearLayout(ctx); container.setOrientation(LinearLayout.VERTICAL); LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); container.setLayoutParams(params); parent.addView(container);// w w w .ja va 2 s . c o m return container; }
From source file:com.example.angelina.travelapp.map.MapActivity.java
/** * Restore map to original size and remove * views associated with displaying route segments. * @return MapFragment - The fragment containing the map *//*from ww w . ja v a 2 s .co m*/ public final MapFragment restoreMapAndRemoveRouteDetail() { // Remove the route directions final LinearLayout layout = (LinearLayout) findViewById(R.id.route_directions_container); layout.setLayoutParams(new CoordinatorLayout.LayoutParams(0, 0)); layout.requestLayout(); // Show the map final FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_fragment_container); final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mapLayout.setLayoutParams(layoutParams); mapLayout.requestLayout(); final FragmentManager fm = getSupportFragmentManager(); final MapFragment mapFragment = (MapFragment) fm.findFragmentById(R.id.map_fragment_container); mapFragment.removeRouteDetail(); return mapFragment; }
From source file:com.example.angelina.travelapp.map.MapActivity.java
/** * Show the list of directions/*from w ww . ja v a2s . co m*/ * @param directions List of DirectionManeuver items containing navigation directions */ public final void showDirections(final List<DirectionManeuver> directions) { final FragmentManager fm = getSupportFragmentManager(); RouteDirectionsFragment routeDirectionsFragment = (RouteDirectionsFragment) fm .findFragmentById(R.id.route_directions_container); if (routeDirectionsFragment == null) { routeDirectionsFragment = RouteDirectionsFragment.newInstance(); ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), routeDirectionsFragment, R.id.route_directions_container, getString(R.string.route_fragment)); } // Show the fragment final LinearLayout layout = (LinearLayout) findViewById(R.id.route_directions_container); layout.setLayoutParams(new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.requestLayout(); // Hide the map final FrameLayout mapLayout = (FrameLayout) findViewById(R.id.map_fragment_container); final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(0, 0); layoutParams.setMargins(0, 0, 0, 0); mapLayout.setLayoutParams(layoutParams); mapLayout.requestLayout(); routeDirectionsFragment.setRoutingDirections(directions); }
From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java
/** * * @return horizontal screen orientation */// w w w . j av a 2s.c om public boolean createRootLayout(LinearLayout l) { l.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); l.setOrientation(LinearLayout.VERTICAL); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { l.setPadding(toPixels(55), toPixels(4), toPixels(55), toPixels(4)); return true; } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { l.setPadding(toPixels(4), toPixels(4), toPixels(4), toPixels(4)); } return false; }
From source file:com.paginatedgallery.PaginatedGalleryAdapter.java
@Override public Object instantiateItem(View collection, int position) { LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenWidth / viewsPerPage)); int size = images.size(); // Log.i(TAG, "Position: "+position + " , Size : "+size); for (int i = 0; i < viewsPerPage; i++) { final int index = position + (position * (viewsPerPage - 1)) + i; Log.i(TAG, "Index: " + index + " , Size : " + size); if (index < size) { View imageView;/* ww w . j ava2s . c om*/ if (isImageUrl) { imageView = new RemoteImageView(context, (String) images.get(index), errorDrawable, errorDrawable, true); } else { imageView = new ImageView(context); ((ImageView) imageView).setImageDrawable((Drawable) images.get(index)); } // imageView.setTag(index); imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mItemClickListener != null) { mItemClickListener.onItemClick(v, index); } } }); imageView.setLayoutParams(new LayoutParams(screenWidth / viewsPerPage, screenWidth / viewsPerPage)); imageView.setPadding(10, 10, 10, 10); layout.addView(imageView); } } ((ViewPager) collection).addView(layout); return layout; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VideoObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w ww . j av a 2 s .co m byte[] raw = obj.getRaw(); if (raw == null) { Pair<JSONObject, byte[]> p = splitRaw(content); content = p.first; raw = p.second; } LinearLayout inner = new LinearLayout(context); inner.setLayoutParams(CommonLayouts.FULL_WIDTH); inner.setOrientation(LinearLayout.HORIZONTAL); frame.addView(inner); ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); BitmapFactory bf = new BitmapFactory(); imageView.setImageBitmap(bf.decodeByteArray(raw, 0, raw.length)); inner.addView(imageView); ImageView iconView = new ImageView(context); iconView.setImageResource(R.drawable.play); iconView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); inner.addView(iconView); }
From source file:com.picogram.awesomeness.SettingsActivity.java
public boolean onPreferenceClick(final Preference preference) { if (preference.getKey().equals("statistics")) { //TODO/*ww w . j a v a 2s . c o m*/ Crouton.makeText(this, "This is not yet implemented", Style.INFO).show(); final AlertDialog dialog = new AlertDialog.Builder(this).create(); final String[] scoresTitles = new String[] { "Games Played", "Games Won", "Taps", "Taps per Puzzle", "Tapes per Minute", "Times Played" }; final int gamesPlayed = 0, gamesWon = 0, taps = 0, tapsPerPuzzle = 0, tapsPerMinute = 0, timePlayed = 0; final int[] scores = { gamesPlayed, gamesWon, taps, tapsPerPuzzle, tapsPerMinute, timePlayed }; // TODO: Implement the preferences and what not. final LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i != scores.length; ++i) { final LinearLayout sub = new LinearLayout(this); sub.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); sub.setOrientation(LinearLayout.HORIZONTAL); TextView tv = new TextView(this); tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); tv.setText(scoresTitles[i]); sub.addView(tv); tv = new TextView(this); tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); tv.setText(scores[i] + ""); sub.addView(tv); ll.addView(sub); } dialog.setView(ll); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogTheme; dialog.show(); dialog.dismiss(); return true; } else if (preference.getKey().equals("changelog")) { // Launch change log dialog final ChangeLogDialog _ChangelogDialog = new ChangeLogDialog(this); _ChangelogDialog.show(); } else if (preference.getKey().equals("licenses")) { // Launch the licenses stuff. Dialog ld = new LicensesDialog(this, R.raw.licenses, false, false).create(); ld.getWindow().getAttributes().windowAnimations = R.style.DialogTheme; ld.show(); } else if (preference.getKey().equals("email")) { final String email = "warner.73+Picogram@wright.edu"; final String subject = "Picogram - <SUBJECT>"; final String message = "Picogram,\n\n<MESSAGE>"; // Contact me. final Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, message); emailIntent.setType("message/rfc822"); this.startActivity(Intent.createChooser(emailIntent, "Send Mail Using :")); overridePendingTransition(R.anim.fadein, R.anim.exit_left); } else if (preference.getKey().equals("rateapp")) { // TODO fix this when we publish. this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=Picogram"))); overridePendingTransition(R.anim.fadein, R.anim.exit_left); final Editor editor = this.prefs.edit(); editor.putBoolean(RateMeMaybe.PREF.DONT_SHOW_AGAIN, true); editor.commit(); } else if (preference.getKey().equals("logoutgoogle")) { //TODO Crouton.makeText(this, "This is not currently supported.", Style.INFO).show(); } else if (preference.getKey().equals("logoutfacebook")) { //TODO Crouton.makeText(this, "This is not currently supported.", Style.INFO).show(); } else if (preference.getKey().equals("resetusername")) { Util.getPreferences(this).edit().putString("username", "").commit(); Util.getPreferences(this).edit().putBoolean("hasLoggedInUsername", false).commit(); } return false; }
From source file:org.alfresco.mobile.android.application.fragments.signin.WelcomeFragment.java
protected void displayLogin() { // Instantiate a ViewPager and a PagerAdapter. Bundle extras = getArguments();/* w ww . j av a 2 s.co m*/ if (extras != null && extras.containsKey(WelcomeActivity.EXTRA_ADD_ACCOUNT)) { hide(R.id.welcome_title); hide(R.id.welcome_pager); hide(R.id.welcome_pager_indicator); LinearLayout layout = (LinearLayout) viewById(R.id.welcome_page_actions_container); layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); } else if (getActivity().findViewById(R.id.double_panel) != null) { hide(R.id.welcome_title); hide(R.id.welcome_pager); hide(R.id.welcome_pager_indicator); LinearLayout layout = (LinearLayout) viewById(R.id.welcome_page_actions_container); layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); } else { // TODO Uncomment with marketing material /* * CircleIndicator defaultIndicator = (CircleIndicator) * viewById(R.type.welcome_pager_indicator); mPager = (ViewPager) * viewById(R.type.welcome_pager); mPagerAdapter = new * ScreenSlidePagerAdapter(getFragmentManager()); * mPager.setAdapter(mPagerAdapter); * defaultIndicator.setViewPager(mPager); */ } }
From source file:org.forgerock.openam.mobile.example.authentication.activities.authenticate.AuthenticateActivity.java
/** * Interrogates the previous Intent. If we were passed here with an authentication callback * to display to the screen, draw it here. * * @param savedInstanceState//from w w w . ja v a 2s . c om */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent previous = getIntent(); final String authCallbackString = previous.getStringExtra(AppConstants.AUTH_CALLBACK); Authenticate auth = null; boolean errored = false; try { auth = AuthenticateFactory.createFromString(authCallbackString); } catch (JSONException e) { Log.e(TAG, "Unable to generate JSON representation of authentication stage.", e); errored = true; } if (errored || auth == null || auth.getCallbacks() == null) { finish(); //if we error here, we cannot continue with the activity } final LinearLayout newLayout = new LinearLayout(this); newLayout.setOrientation(LinearLayout.VERTICAL); newLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); //for each callback returned to us, create a drawable callback from it, auth not null here final DrawableCallback[] dcs = new DrawableCallback[auth.getCallbacks().length]; //todo: clean this up, take it away from here. for (int i = 0; i < auth.getCallbacks().length; i++) { Callback cb = auth.getCallbacks()[i]; if (cb.getType().equals(PasswordCallback.TYPE)) { dcs[i] = new PasswordCallback(cb.getOutput()[0].getValue(), cb.getInput()[0].getName(), this); } else if (cb.getType().equals(NameCallback.TYPE)) { dcs[i] = new NameCallback(cb.getOutput()[0].getValue(), cb.getInput()[0].getName(), this); } } //put our new drawables on to the screen for (DrawableCallback dc : dcs) { newLayout.addView(dc.getDisplayElement()); } //add a submit button for the user to press Button submitButton = createSubmitButton(dcs, authCallbackString); newLayout.addView(submitButton); setContentView(newLayout); }