Java Code Examples for android.widget.ImageView#setMaxHeight()
The following examples show how to use
android.widget.ImageView#setMaxHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FullHintActivity.java From hintcase with Apache License 2.0 | 6 votes |
@NonNull private ImageView getGifLoadedUsingGlide() { ImageView animatedImageView = new ImageView(getActivity()); animatedImageView.setMaxHeight(900); Glide.with(getActivity()) .load(R.drawable.animated_image) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .thumbnail(Glide.with(getActivity()) .load(R.drawable.animated_image) .asBitmap() .transcode(new BitmapToGlideDrawableTranscoder(getActivity()), GlideDrawable.class) .diskCacheStrategy(DiskCacheStrategy.ALL) ) .into(animatedImageView); return animatedImageView; }
Example 2
Source File: NewsDetailsFragment.java From ForPDA with GNU General Public License v3.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); baseInflateFragment(inflater, R.layout.fragment_article); ViewStub viewStub = (ViewStub) findViewById(R.id.toolbar_content); viewStub.setLayoutResource(R.layout.toolbar_news_details); viewStub.inflate(); fragmentsPager = (ViewPager) findViewById(R.id.view_pager); webViewContainer = (FrameLayout) findViewById(R.id.swipe_refresh_list); progressBar = (ProgressBar) findViewById(R.id.progress_bar); detailsImage = (ImageView) findViewById(R.id.article_image); detailsTitle = (TextView) findViewById(R.id.article_title); detailsNick = (TextView) findViewById(R.id.article_nick); detailsCount = (TextView) findViewById(R.id.article_comments_count); detailsDate = (TextView) findViewById(R.id.article_date); imageProgressBar = (ProgressBar) findViewById(R.id.article_progress_bar); detailsImage.setMaxHeight(App.px24 * 10); AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams(); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED); toolbarLayout.setLayoutParams(params); return view; }
Example 3
Source File: CustomBanner.java From commcare-android with Apache License 2.0 | 6 votes |
public static boolean useCustomBanner(Context context, int screenHeight, int screenWidth, @NonNull ImageView topBannerImageView, Banner banner) { String customBannerURI = banner.getBannerURI(); if (!"".equals(customBannerURI)) { int maxBannerHeight = screenHeight / 4; Bitmap bitmap = MediaUtil.inflateDisplayImage(context, customBannerURI, screenWidth, maxBannerHeight); if (bitmap != null) { topBannerImageView.setMaxHeight(maxBannerHeight); topBannerImageView.setImageBitmap(bitmap); return true; } } return false; }
Example 4
Source File: MoDialogView.java From a with GNU General Public License v3.0 | 5 votes |
/** * 显示图像和文本 */ public void showImageText(Bitmap bitmap, String text) { removeAllViews(); LayoutInflater.from(getContext()).inflate(R.layout.mo_dialog_image_text, this, true); CardView cardView = findViewById(R.id.cv_content); cardView.setOnClickListener(null); ImageView imageView = findViewById(R.id.image_view); TextView tvCanCopy = findViewById(R.id.tv_can_copy); int imageWidth = Math.min(cardView.getWidth(), cardView.getHeight()); imageView.setMaxWidth(imageWidth - 20); imageView.setMaxHeight(imageWidth - 20); imageView.setImageBitmap(bitmap); tvCanCopy.setText(text); }
Example 5
Source File: ImageViewUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 设置 ImageView 最大高度 * @param imageView ImageView * @param maxHeight 最大高度 * @return {@link ImageView} */ public static ImageView setMaxHeight(final ImageView imageView, final int maxHeight) { if (imageView != null) { imageView.setMaxHeight(maxHeight); } return imageView; }
Example 6
Source File: MoDialogView.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
/** * 显示图像和文本 */ public void showImageText(Bitmap bitmap, String text) { removeAllViews(); LayoutInflater.from(getContext()).inflate(R.layout.mo_dialog_image_text, this, true); CardView cardView = findViewById(R.id.cv_content); cardView.setOnClickListener(null); ImageView imageView = findViewById(R.id.image_view); TextView tvCanCopy = findViewById(R.id.tv_can_copy); int imageWidth = Math.min(cardView.getWidth(), cardView.getHeight()); imageView.setMaxWidth(imageWidth - 20); imageView.setMaxHeight(imageWidth - 20); imageView.setImageBitmap(bitmap); tvCanCopy.setText(text); }
Example 7
Source File: InfoLayoutHelper.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
public static void addResourceImage(Activity activity, LinearLayout layout, int imgResource, int width, int height) { ImageView image = new ImageView(activity); image.setImageResource(imgResource); if (width > 0) image.setMaxWidth(width); if (height > 0) image.setMaxHeight(height); image.setScaleType(ImageView.ScaleType.CENTER_INSIDE); layout.addView(image); }
Example 8
Source File: ZjbImageLoader.java From Android-Application-ZJB with Apache License 2.0 | 5 votes |
/** * url的格式如下 * http://site.com/image.png // from Web * file:///mnt/sdcard/image.png // from SD card * file:///mnt/sdcard/video.mp4 // from SD card (video thumbnail) * content://media/external/images/media/13 // from content provider * content://media/external/video/media/13 // from content provider (video thumbnail) * assets://image.png // from assets * drawable:// + R.drawable.img // from drawables (non-9patch images) * * @param view */ public void into(View view) { if (null != view) { //1.设置尺寸 if (view instanceof ImageView) { ImageView imageView = (ImageView) view; if (mQiniuWidth > 0 && mQiniuHeight > 0) { imageView.setMaxHeight(mQiniuHeight); imageView.setMaxWidth(mQiniuWidth); } if (mDefaultDrawable != null) { imageView.setImageDrawable(mDefaultDrawable); } else if (mDefaultRes != 0) { imageView.setImageResource(mDefaultRes); } } else if (view instanceof AnimationImageView) { AnimationImageView imageSwitcher = (AnimationImageView) view; if (mQiniuWidth > 0 && mQiniuHeight > 0) { imageSwitcher.setQiniuHeight(mQiniuHeight); imageSwitcher.setQiniuWidth(mQiniuWidth); } if (mDefaultDrawable != null) { imageSwitcher.setImageDrawable(mDefaultDrawable); } else if (mDefaultRes != 0) { imageSwitcher.setImageResource(mDefaultRes); } } } ZjbImageLoader.display(this.mUrl, view, this.build(), this.mImageLoadingListener, this.mImageLoadingProgressListener); }
Example 9
Source File: TGABitmapViewerActivity.java From TGAReader with MIT License | 5 votes |
private ImageView createTGAImageView(String path) { Bitmap bitmap = createTGABitmap(path); if(bitmap != null) { ImageView imageView = new ImageView(this); imageView.setImageBitmap(bitmap); imageView.setAdjustViewBounds(true); imageView.setMaxWidth(128); imageView.setMaxHeight(128); imageView.setPadding(8, 8, 0, 0); return imageView; } return null; }
Example 10
Source File: OnboardingFragment.java From Onboarder with MIT License | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_onboarding, container, false); // Inflate the layout for this fragment Bundle bundle = getArguments(); /* The title which is displayed at the top of the fragment */ String title = bundle.getString(TITLE, null); /* The body text which is displayed in the middle of the fragment */ String bodyText = bundle.getString(BODY_TEXT, null); /* The image resource which is displayed in the middle of the fragment, above the text */ int imageResId = bundle.getInt(IMAGE_RESOURCE_ID, -1); /* The position that the fragment is in adapter */ final int position = bundle.getInt(POSITION, 0); /* The button text (if the user set any) */ String buttonText = bundle.getString(BUTTON_TEXT, null); /* Max height for the image (if not, it just scales it up) */ int maxImageHeight = bundle.getInt(MAX_IMAGE_HEIGHT,-1); @ColorRes int titleTextColor = bundle.getInt(TITLE_TEXT_COLOR, -1); @ColorRes int bodyTextColor = bundle.getInt(BODY_TEXT_COLOR,-1); TextView titleTextView = (TextView) view.findViewById(R.id.onboarding_fragment_title); TextView bodyTextView = (TextView) view.findViewById(R.id.onboarding_fragment_body_text); ImageView imageView = (ImageView) view.findViewById(R.id.onboarding_fragment_image); Button button = (Button) view.findViewById(R.id.onboarding_fragment_button); //Set the title if (title !=null) { titleTextView.setText(title); //Set the body text color if (titleTextColor!=-1) { titleTextView.setTextColor(getResources().getColor(titleTextColor)); } } else { titleTextView.setVisibility(View.GONE); } //Set the body text if (bodyText !=null) { bodyTextView.setText(bodyText); //Set the body text color if (bodyTextColor!=-1) { bodyTextView.setTextColor(getResources().getColor(bodyTextColor)); } } else { bodyTextView.setVisibility(View.GONE); } //Set the image if (imageResId !=-1) { imageView.setImageResource(imageResId); //Set the max image height (if it was set) if (maxImageHeight !=-1) { imageView.setMaxHeight(maxImageHeight); } } else { imageView.setVisibility(View.GONE); } //Set the button text and link it to the method if (buttonText!=null) { button.setText(buttonText); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clickOnboardingButton(position); } }); } else { button.setVisibility(View.GONE); } return view; }
Example 11
Source File: MucDetailsContextMenuHelper.java From Pix-Art-Messenger with GNU General Public License v3.0 | 4 votes |
public static boolean onContextItemSelected(MenuItem item, User user, XmppActivity activity, final String fingerprint) { final Conversation conversation = user.getConversation(); final XmppConnectionService.OnAffiliationChanged onAffiliationChanged = activity instanceof XmppConnectionService.OnAffiliationChanged ? (XmppConnectionService.OnAffiliationChanged) activity : null; final Jid jid = user.getRealJid(); final Account account = conversation.getAccount(); final Contact contact = jid == null ? null : account.getRoster().getContact(jid); switch (item.getItemId()) { case R.id.action_show_avatar: final ImageView view = new ImageView(activity); view.setAdjustViewBounds(true); view.setMaxHeight(R.dimen.avatar_big); view.setMaxWidth(R.dimen.avatar_big); view.setBackgroundColor(Color.WHITE); view.setScaleType(ImageView.ScaleType.FIT_XY); AvatarWorkerTask.loadAvatar(user, view, R.dimen.avatar_big); final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setView(view); builder.create().show(); return true; case R.id.action_contact_details: if (contact != null) { activity.switchToContactDetails(contact, fingerprint); } return true; case R.id.start_conversation: startConversation(user, activity); return true; case R.id.add_contact: activity.showAddToRosterDialog(contact); return true; case R.id.give_admin_privileges: activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.ADMIN, onAffiliationChanged); return true; case R.id.give_membership: case R.id.remove_admin_privileges: case R.id.revoke_owner_privileges: activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged); return true; case R.id.give_owner_privileges: activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.OWNER, onAffiliationChanged); return true; case R.id.remove_membership: activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.NONE, onAffiliationChanged); return true; case R.id.kick_from_room: kickFromRoom(user, activity, onAffiliationChanged); return true; case R.id.ban_from_room: banFromRoom(user, activity, onAffiliationChanged); return true; case R.id.send_private_message: if (activity instanceof ConversationsActivity) { ConversationFragment conversationFragment = ConversationFragment.get(activity); if (conversationFragment != null) { activity.invalidateOptionsMenu(); conversationFragment.privateMessageWith(user.getFullJid()); return true; } } activity.privateMsgInMuc(conversation, user.getName()); return true; case R.id.invite: if (user.getAffiliation().ranks(MucOptions.Affiliation.MEMBER)) { activity.xmppConnectionService.directInvite(conversation, jid.asBareJid()); } else { activity.xmppConnectionService.invite(conversation, jid); } return true; case R.id.context_muc_contact_block_unblock: try { activity.xmppConnectionService.sendBlockRequest(new RawBlockable(account, user.getFullJid()), false); activity.xmppConnectionService.leaveMuc(conversation); activity.xmppConnectionService.joinMuc(conversation); } catch (Exception e) { e.printStackTrace(); } return true; case R.id.highlight_in_muc: activity.highlightInMuc(conversation, user.getName()); return true; default: return false; } }
Example 12
Source File: MediaLayout.java From commcare-android with Apache License 2.0 | 4 votes |
private View setupImage(String imageURI, String bigImageURI) { View mediaPane = null; try { int[] maxBounds = getMaxCenterViewBounds(); final String imageFilename = ReferenceManager.instance().DeriveReference(imageURI).getLocalURI(); final File imageFile = new File(imageFilename); if (imageFile.exists()) { Bitmap b = MediaUtil.inflateDisplayImage(getContext(), imageURI, maxBounds[0], maxBounds[1]); if (b != null) { ImageView mImageView = new ImageView(getContext()); if (useResizingImageView()) { mImageView = new ResizingImageView(getContext(), imageURI, bigImageURI); mImageView.setAdjustViewBounds(true); mImageView.setMaxWidth(maxBounds[0]); mImageView.setMaxHeight(maxBounds[1]); } else { mImageView.setScaleType(ImageView.ScaleType.CENTER); } mImageView.setPadding(10, 10, 10, 10); if (imageFilename.toLowerCase().endsWith(IMAGE_GIF_EXTENSION)) { Glide.with(mImageView).asGif() .override(b.getWidth(), b.getHeight()) .load(imageFilename) .into(mImageView); b.recycle(); } else { mImageView.setImageBitmap(b); } mImageView.setId(IMAGE_VIEW_ID); mediaPane = mImageView; } } else { // An error hasn't been logged. We should have an image, but the file doesn't // exist. mediaPane = getMissingMediaView(imageURI, StringUtils.getStringRobust(getContext(), R.string.video_download_prompt), true); } } catch (InvalidReferenceException e) { Log.e(TAG, "image invalid reference exception"); e.printStackTrace(); } return mediaPane; }
Example 13
Source File: MessageBoard.java From apigee-android-sdk with Apache License 2.0 | 4 votes |
private void createPosts() { //get total number of posts from Posts.java int numPosts = ((Messagee) this.getApplication()).messController.getPosts().getNumPosts(); //clear all posts from llPosts llPosts.removeAllViews(); //create individual post layouts and add to llPosts for(int i=numPosts-1; i>=0; i--){ /*cell layout: |picture| |arrow| |Username| | | |image| |Post ............| | | | | |Post ............| | | | | |Post ............| */ //create layout for post cell LinearLayout llCell = new LinearLayout(this); llCell.setOrientation(LinearLayout.HORIZONTAL); //create layout to hold username and post message LinearLayout llUserAndPost = new LinearLayout(this); llUserAndPost.setOrientation(LinearLayout.VERTICAL); //Create image holder for user image ImageView postImage = new ImageView(this); postImage.setMaxWidth(dpToPix(50)); postImage.setBackgroundColor(getResources().getColor(R.color.black)); postImage.setPadding(dpToPix(1), dpToPix(1), dpToPix(1), dpToPix(1)); postImage.setMaxHeight(dpToPix(50)); postImage.setScaleType(ImageView.ScaleType.FIT_XY); postImage.setAdjustViewBounds(true); String imURL = ((Messagee) this.getApplication()).messController.getPosts().getPicURLByIndex(i); postImage.setImageDrawable(((Messagee) this.getApplication()).messController.getPostImages().getImage(imURL)); //draw arrow ImageView arrowImage = new ImageView(this); arrowImage.setMaxWidth(dpToPix(30)); arrowImage.setMaxHeight(dpToPix(30)); arrowImage.setScaleType(ImageView.ScaleType.FIT_XY); arrowImage.setAdjustViewBounds(true); arrowImage.setImageDrawable(getResources().getDrawable(R.drawable.arrow)); //text holder for username String username = ((Messagee) this.getApplication()).messController.getPosts().getPostNameByIndex(i); TextView usernameText = new TextView(this); usernameText.setPadding(0, 0, 0, dpToPix(4)); usernameText.setTextColor(getResources().getColor(R.color.black)); usernameText.setText(username); usernameText.setTypeface(null,1); usernameText.setTextSize(17); //text holder for message String postMessage = ((Messagee) this.getApplication()).messController.getPosts().getPostMessageByIndex(i); TextView postText = new TextView(this); postText.setTextColor(getResources().getColor(R.color.post_message_gray)); postText.setText(postMessage); postText.setTextSize(17); //add username and post text to a linear layout llUserAndPost.addView(usernameText); llUserAndPost.addView(postText); //set layout properties and add rounded rectangle border llUserAndPost.setBackgroundDrawable(getResources().getDrawable(R.drawable.rounded_corners_white)); llUserAndPost.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); llUserAndPost.setPadding(dpToPix(14), dpToPix(10), dpToPix(14), dpToPix(10)); //add images and text layout to create the post layout llCell.addView(postImage); llCell.addView(arrowImage); llCell.addView(llUserAndPost); llCell.setPadding(dpToPix(10f), dpToPix(18f), dpToPix(10f), 0); //add post layout to layout containing all posts llPosts.addView(llCell); } }