List of usage examples for android.widget FrameLayout setPadding
public void setPadding(int left, int top, int right, int bottom)
From source file:com.todoroo.astrid.activity.FilterListFragment.java
public static void showCreateShortcutDialog(final Activity activity, final Intent shortcutIntent, final Filter filter) { FrameLayout frameLayout = new FrameLayout(activity); frameLayout.setPadding(10, 0, 10, 0); final EditText editText = new EditText(activity); if (filter.listingTitle == null) filter.listingTitle = ""; //$NON-NLS-1$ editText.setText(filter.listingTitle.replaceAll("\\(\\d+\\)$", "").trim()); //$NON-NLS-1$ //$NON-NLS-2$ frameLayout.addView(editText, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT)); final Runnable createShortcut = new Runnable() { @Override/*from w w w . j a v a 2 s .c om*/ public void run() { String label = editText.getText().toString(); createShortcut(activity, filter, shortcutIntent, label); } }; editText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL) { createShortcut.run(); return true; } return false; } }); new AlertDialog.Builder(activity).setTitle(R.string.FLA_shortcut_dialog_title) .setMessage(R.string.FLA_shortcut_dialog).setView(frameLayout) .setIcon(android.R.drawable.ic_dialog_info) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { createShortcut.run(); } }).setNegativeButton(android.R.string.cancel, null).show().setOwnerActivity(activity); }
From source file:org.brandroid.openmanager.fragments.DialogHandler.java
public static AlertDialog showSeekBarDialog(final Context context, String title, int progress, int max, OnSeekBarChangeListener onSeekListener) { FrameLayout view = new FrameLayout(context); SeekBar sb = new SeekBar(context); view.addView(sb);/* ww w. j a va 2s .c o m*/ view.setPadding(20, 20, 20, 20); sb.setOnSeekBarChangeListener(onSeekListener); sb.setProgress(progress); sb.setMax(max); return new AlertDialog.Builder(context).setTitle(title).setView(view).show(); }
From source file:org.telegram.ui.IdenticonActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/* w w w . j a va 2 s.c o m*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); fragmentView = new LinearLayout(context); LinearLayout linearLayout = (LinearLayout) fragmentView; linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setWeightSum(100); linearLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); FrameLayout frameLayout = new FrameLayout(context); frameLayout.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); ImageView identiconView = new ImageView(context); identiconView.setScaleType(ImageView.ScaleType.FIT_XY); frameLayout.addView(identiconView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); frameLayout = new FrameLayout(context); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.background)); frameLayout.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); TextView textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLinksClickable(true); textView.setClickable(true); textView.setMovementMethod(new LinkMovementMethodMy()); //textView.setAutoLinkMask(Linkify.WEB_URLS); textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR); textView.setGravity(Gravity.CENTER); frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id); if (encryptedChat != null) { IdenticonDrawable drawable = new IdenticonDrawable(); identiconView.setImageDrawable(drawable); drawable.setEncryptedChat(encryptedChat); TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id); SpannableStringBuilder hash = new SpannableStringBuilder(); if (encryptedChat.key_hash.length > 16) { String hex = Utilities.bytesToHex(encryptedChat.key_hash); for (int a = 0; a < 32; a++) { if (a != 0) { if (a % 8 == 0) { hash.append('\n'); } else if (a % 4 == 0) { hash.append(' '); } } hash.append(hex.substring(a * 2, a * 2 + 2)); hash.append(' '); } hash.append("\n\n"); } hash.append(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name))); final String url = "telegram.org"; int index = hash.toString().indexOf(url); if (index != -1) { hash.setSpan( new URLSpanReplacement( LocaleController.getString("EncryptionKeyLink", R.string.EncryptionKeyLink)), index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } textView.setText(hash); } return fragmentView; }
From source file:fr.matthiasbosc.translucentmap.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { getWindow().requestFeature(Window.FEATURE_ACTION_BAR); getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); settings = getSharedPreferences(PREFERENCES, 0); editor = settings.edit();// w w w. j a v a 2 s . c o m setContentView(R.layout.activity_main); if (isGMSInstalled() == ConnectionResult.SUCCESS) { if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) && (!isLowRamDevice())) { mWindow = getWindow(); mWindow.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); mWindow.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); hasTranslucentBars = true; firstRun(); } mActionBar = getActionBar(); if (mActionBar != null) { mActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#3F000000"))); mActionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#3F000000"))); getMap(); } } else { FrameLayout fl = (FrameLayout) findViewById(R.id.map); fl.setPadding(0, getActionBarHeight(), 0, 0); } }
From source file:uk.co.senab.photup.PhotoViewerActivity.java
private void showCaptionDialog() { final PhotoUpload currentUpload = getCurrentUpload(); if (null != currentUpload) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.photo_caption); builder.setIcon(R.drawable.ic_action_caption); // Set an EditText view to get user input final FrameLayout layout = new FrameLayout(this); final int margin = getResources().getDimensionPixelSize(R.dimen.spacing); layout.setPadding(margin, margin, margin, margin); final EditText input = new EditText(this); input.setMinLines(2);//from ww w. j a v a 2s . co m input.setText(currentUpload.getCaption()); layout.addView(input); builder.setView(layout); final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { switch (whichButton) { case AlertDialog.BUTTON_POSITIVE: currentUpload.setCaption(input.getText().toString()); getSupportActionBar().setTitle(currentUpload.toString()); break; case AlertDialog.BUTTON_NEGATIVE: default: dialog.dismiss(); break; } } }; builder.setPositiveButton(android.R.string.ok, listener); builder.setNegativeButton(android.R.string.cancel, listener); builder.show(); } }
From source file:com.itude.mobile.mobbl.core.controller.util.MBBasicViewController.java
/** * @see android.support.v4.app.DialogFragment#onStart() * //from w w w . j a v a 2s.c o m * This method is used to do stuff with the AlertDialog created in onCreateDialog based * on optional parameters passed to this DialogFragment. */ @Override public void onStart() { super.onStart(); // At this point, Dialog.show is invoked; resolves the issue of first calling requestFeature // before doing view stuff. But this is only for the AlertDialog, i.e. closable dialogs if (getShowsDialog() && _isDialogClosable) { FrameLayout layout = (FrameLayout) getDialog().findViewById(android.R.id.custom); if (layout != null) layout.setPadding(0, 0, 0, 0); styleCloseButton(); } if (getShowsDialog() && _isDialogFullscreen) { Window window = getDialog().getWindow(); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }
From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java
@Override public synchronized void showProgressIndicatorInTool() { MBToolDefinition refreshToolDef = getRefreshToolDef(); Menu menu = _menu;//from w w w .j a v a 2s .c om if (refreshToolDef != null && menu != null) { final MenuItem item = menu.findItem(refreshToolDef.getName().hashCode()); ImageView rotationImage = getRotationImage(); float imageWidth = rotationImage.getDrawable().getIntrinsicWidth(); int framePadding = (int) ((ScreenUtil.convertDimensionPixelsToPixels(_context, 80) - imageWidth) / 2); final FrameLayout frameLayout = new FrameLayout(_context); frameLayout.setLayoutParams( new FrameLayout.LayoutParams(ScreenUtil.convertDimensionPixelsToPixels(_context, 80), LayoutParams.WRAP_CONTENT, Gravity.CENTER)); frameLayout.setPadding(framePadding, 0, framePadding, 0); frameLayout.addView(rotationImage); MBViewManager.getInstance().runOnUiThread(new MBThread() { @Override public void runMethod() { //item.setIcon(null); MenuItemCompat.setActionView(item, frameLayout); getRotationImage().getAnimation().startNow(); } }); } }
From source file:com.putaotown.views.PagerSlidingTabStrip.java
private void addIconTab(final int position, int resId) { boolean isMessage = false; //?? if (resId == R.drawable.iconfont_message || resId == R.drawable.iconfont_message_press) isMessage = true;//from w w w . j a v a 2 s. co m ImageButton tab = new ImageButton(getContext()); // LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams( (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabWidth, getResources().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabWidth, getResources().getDisplayMetrics())); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()); if (isMessage) { FrameLayout.LayoutParams paramx = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabWidth, getResources().getDisplayMetrics())); FrameLayout flayout = new FrameLayout(this.getContext()); param.gravity = Gravity.RIGHT; flayout.setLayoutParams(param); flayout.setPadding(padding, padding, padding, padding); View view = inflate(this.getContext(), R.layout.actionbar_mess_view, null); this.messRedPos = view.findViewById(R.id.actionbar_mess_redpos); this.messImage = (ImageView) view.findViewById(R.id.actionbar_mess_icon); flayout.addView(view); flayout.setTag("mess"); //?? addTab(position, flayout); } else { tab.setLayoutParams(param); tab.setPadding(padding, padding, padding, padding); tab.setImageResource(resId); tab.setScaleType(ScaleType.CENTER_INSIDE); tab.setAdjustViewBounds(true); addTab(position, tab); } }
From source file:com.facebook.android.friendsmash.ScoreboardFragment.java
private void populateScoreboard() { // Ensure all components are firstly removed from scoreboardContainer scoreboardContainer.removeAllViews(); // Ensure the progress spinner is hidden progressContainer.setVisibility(View.INVISIBLE); // Ensure scoreboardEntriesList is not null and not empty first if (application.getScoreboardEntriesList() == null || application.getScoreboardEntriesList().size() <= 0) { closeAndShowError(getResources().getString(R.string.error_no_scores)); } else {/* w w w. ja va2s .c o m*/ // Iterate through scoreboardEntriesList, creating new UI elements for each entry int index = 0; Iterator<ScoreboardEntry> scoreboardEntriesIterator = application.getScoreboardEntriesList().iterator(); while (scoreboardEntriesIterator.hasNext()) { // Get the current scoreboard entry final ScoreboardEntry currentScoreboardEntry = scoreboardEntriesIterator.next(); // FrameLayout Container for the currentScoreboardEntry ... // Create and add a new FrameLayout to display the details of this entry FrameLayout frameLayout = new FrameLayout(getActivity()); scoreboardContainer.addView(frameLayout); // Set the attributes for this frameLayout int topPadding = getResources().getDimensionPixelSize(R.dimen.scoreboard_entry_top_margin); frameLayout.setPadding(0, topPadding, 0, 0); // ImageView background image ... { // Create and add an ImageView for the background image to this entry ImageView backgroundImageView = new ImageView(getActivity()); frameLayout.addView(backgroundImageView); // Set the image of the backgroundImageView String uri = "drawable/scores_stub_even"; if (index % 2 != 0) { // Odd entry uri = "drawable/scores_stub_odd"; } int imageResource = getResources().getIdentifier(uri, null, getActivity().getPackageName()); Drawable image = getResources().getDrawable(imageResource); backgroundImageView.setImageDrawable(image); // Other attributes of backgroundImageView to modify FrameLayout.LayoutParams backgroundImageViewLayoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); int backgroundImageViewMarginTop = getResources() .getDimensionPixelSize(R.dimen.scoreboard_background_imageview_margin_top); backgroundImageViewLayoutParams.setMargins(0, backgroundImageViewMarginTop, 0, 0); backgroundImageViewLayoutParams.gravity = Gravity.LEFT; if (index % 2 != 0) { // Odd entry backgroundImageViewLayoutParams.gravity = Gravity.RIGHT; } backgroundImageView.setLayoutParams(backgroundImageViewLayoutParams); } // ProfilePictureView of the current user ... { // Create and add a ProfilePictureView for the current user entry's profile picture ProfilePictureView profilePictureView = new ProfilePictureView(getActivity()); frameLayout.addView(profilePictureView); // Set the attributes of the profilePictureView int profilePictureViewWidth = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_width); FrameLayout.LayoutParams profilePictureViewLayoutParams = new FrameLayout.LayoutParams( profilePictureViewWidth, profilePictureViewWidth); int profilePictureViewMarginLeft = 0; int profilePictureViewMarginTop = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_top); int profilePictureViewMarginRight = 0; int profilePictureViewMarginBottom = 0; if (index % 2 == 0) { profilePictureViewMarginLeft = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_left); } else { profilePictureViewMarginRight = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_right); } profilePictureViewLayoutParams.setMargins(profilePictureViewMarginLeft, profilePictureViewMarginTop, profilePictureViewMarginRight, profilePictureViewMarginBottom); profilePictureViewLayoutParams.gravity = Gravity.LEFT; if (index % 2 != 0) { // Odd entry profilePictureViewLayoutParams.gravity = Gravity.RIGHT; } profilePictureView.setLayoutParams(profilePictureViewLayoutParams); // Finally set the id of the user to show their profile pic profilePictureView.setProfileId(currentScoreboardEntry.getId()); } // LinearLayout to hold the text in this entry // Create and add a LinearLayout to hold the TextViews LinearLayout textViewsLinearLayout = new LinearLayout(getActivity()); frameLayout.addView(textViewsLinearLayout); // Set the attributes for this textViewsLinearLayout FrameLayout.LayoutParams textViewsLinearLayoutLayoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); int textViewsLinearLayoutMarginLeft = 0; int textViewsLinearLayoutMarginTop = getResources() .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_top); int textViewsLinearLayoutMarginRight = 0; int textViewsLinearLayoutMarginBottom = 0; if (index % 2 == 0) { textViewsLinearLayoutMarginLeft = getResources() .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_left); } else { textViewsLinearLayoutMarginRight = getResources() .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_right); } textViewsLinearLayoutLayoutParams.setMargins(textViewsLinearLayoutMarginLeft, textViewsLinearLayoutMarginTop, textViewsLinearLayoutMarginRight, textViewsLinearLayoutMarginBottom); textViewsLinearLayoutLayoutParams.gravity = Gravity.LEFT; if (index % 2 != 0) { // Odd entry textViewsLinearLayoutLayoutParams.gravity = Gravity.RIGHT; } textViewsLinearLayout.setLayoutParams(textViewsLinearLayoutLayoutParams); textViewsLinearLayout.setOrientation(LinearLayout.VERTICAL); // TextView with the position and name of the current user { // Set the text that should go in this TextView first int position = index + 1; String currentScoreboardEntryTitle = position + ". " + currentScoreboardEntry.getName(); // Create and add a TextView for the current user position and first name TextView titleTextView = new TextView(getActivity()); textViewsLinearLayout.addView(titleTextView); // Set the text and other attributes for this TextView titleTextView.setText(currentScoreboardEntryTitle); titleTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerNameFont); } // TextView with the score of the current user { // Create and add a TextView for the current user score TextView scoreTextView = new TextView(getActivity()); textViewsLinearLayout.addView(scoreTextView); // Set the text and other attributes for this TextView scoreTextView.setText("Score: " + currentScoreboardEntry.getScore()); scoreTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerScoreFont); } // Finally make this frameLayout clickable so that a game starts with the user smashing // the user represented by this frameLayout in the scoreContainer frameLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Bundle bundle = new Bundle(); bundle.putString("user_id", currentScoreboardEntry.getId()); Intent i = new Intent(); i.putExtras(bundle); getActivity().setResult(Activity.RESULT_FIRST_USER, i); getActivity().finish(); return false; } else { return true; } } }); // Increment the index before looping back index++; } } }
From source file:com.wellsandwhistles.android.redditsp.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getActivity(); if (mPost == null) { final SRThemeAttributes attr = new SRThemeAttributes(context); mPost = post;/*w w w . j a v a2s. co m*/ isArchived = post.isArchived; final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost); mCommentListingManager.addPostHeader(postHeader); ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); if (post.src.getSelfText() != null) { final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.srMainTextCol, 14f * mCommentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); final FrameLayout paddingLayout = new FrameLayout(context); final TextView collapsedView = new TextView(context); collapsedView.setText("[ + ] " + getActivity().getString(R.string.collapsed_self_post)); collapsedView.setVisibility(View.GONE); collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.addView(selfText); paddingLayout.addView(collapsedView); paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selfText.getVisibility() == View.GONE) { selfText.setVisibility(View.VISIBLE); collapsedView.setVisibility(View.GONE); } else { selfText.setVisibility(View.GONE); collapsedView.setVisibility(View.VISIBLE); } } }); // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); mCommentListingManager.addPostSelfText(paddingLayout); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getActivity().setTitle(post.src.getTitle()); } if (mCommentListingManager.isSearchListing()) { final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title); mCommentListingManager.addNotification(searchCommentThreadView); } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL && mAllUrls.get(0).asPostCommentListURL().commentId != null) { final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title); mCommentListingManager.addNotification(specificCommentThreadView); } // TODO pref (currently 10 mins) if (mCachedTimestamp != null && SRTime.since(mCachedTimestamp) > 10 * 60 * 1000) { final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.cached_header, null, false); cacheNotif.setText(getActivity().getString(R.string.listing_cached, SRTime.formatDateTime(mCachedTimestamp, getActivity()))); mCommentListingManager.addNotification(cacheNotif); } } }