android.widget.ImageView#setMaxWidth ( )源码实例Demo

下面列出了android.widget.ImageView#setMaxWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: delion   文件: PaymentRequestSection.java
private View createIcon(GridLayout parent, int rowIndex) {
    // The icon has a pre-defined width.
    ImageView icon = new ImageView(parent.getContext());
    icon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    icon.setBackgroundResource(R.drawable.payments_ui_logo_bg);
    icon.setImageResource(mOption.getDrawableIconId());
    icon.setMaxWidth(mIconMaxWidth);

    // The icon floats to the right of everything.
    GridLayout.LayoutParams iconParams = new GridLayout.LayoutParams(
            GridLayout.spec(rowIndex, 1, GridLayout.CENTER), GridLayout.spec(2, 1));
    iconParams.topMargin = mVerticalMargin;
    ApiCompatibilityUtils.setMarginStart(iconParams, mLargeSpacing);
    parent.addView(icon, iconParams);

    icon.setOnClickListener(OptionSection.this);
    return icon;
}
 
源代码2 项目: AndroidChromium   文件: PaymentRequestSection.java
private View createOptionIcon(GridLayout parent, int rowIndex, boolean editIconExists) {
    // The icon has a pre-defined width.
    ImageView optionIcon = new ImageView(parent.getContext());
    optionIcon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    optionIcon.setBackgroundResource(R.drawable.payments_ui_logo_bg);
    optionIcon.setImageDrawable(mOption.getDrawableIcon());
    optionIcon.setMaxWidth(mIconMaxWidth);

    // Place option icon at column three if no edit icon.
    int columnStart = editIconExists ? 2 : 3;
    GridLayout.LayoutParams iconParams = new GridLayout.LayoutParams(
            GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
            GridLayout.spec(columnStart, 1));
    iconParams.topMargin = mVerticalMargin;
    parent.addView(optionIcon, iconParams);

    optionIcon.setOnClickListener(OptionSection.this);
    return optionIcon;
}
 
源代码3 项目: TurboLauncher   文件: PagedViewWidget.java
public void applyFromAppWidgetProviderInfo(AppWidgetProviderInfo info,
        int maxWidth, int[] cellSpan, WidgetPreviewLoader loader) {
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

    mIsAppWidget = true;
    mInfo = info;
    final ImageView image = (ImageView) findViewById(R.id.widget_preview);
    if (maxWidth > -1) {
        image.setMaxWidth(maxWidth);
    }
    final TextView name = (TextView) findViewById(R.id.widget_name);
    name.setText(info.label);
    final TextView dims = (TextView) findViewById(R.id.widget_dims);
    if (dims != null) {
        int hSpan = Math.min(cellSpan[0], (int) grid.numColumns);
        int vSpan = Math.min(cellSpan[1], (int) grid.numRows);
        dims.setText(String.format(mDimensionsFormatString, hSpan, vSpan));
    }
    mWidgetPreviewLoader = loader;
}
 
源代码4 项目: 365browser   文件: PaymentRequestSection.java
private View createOptionIcon(GridLayout parent, int rowIndex, boolean editIconExists) {
    // The icon has a pre-defined width.
    ImageView optionIcon = new ImageView(parent.getContext());
    optionIcon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    if (mOption.isEditable()) {
        optionIcon.setMaxWidth(mEditableOptionIconMaxWidth);
    } else {
        optionIcon.setMaxWidth(mNonEditableOptionIconMaxWidth);
    }
    optionIcon.setAdjustViewBounds(true);
    optionIcon.setImageDrawable(mOption.getDrawableIcon());

    // Place option icon at column three if no edit icon.
    int columnStart = editIconExists ? 2 : 3;
    GridLayout.LayoutParams iconParams =
            new GridLayout.LayoutParams(GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
                    GridLayout.spec(columnStart, 1, GridLayout.CENTER));
    iconParams.topMargin = mVerticalMargin;
    parent.addView(optionIcon, iconParams);

    optionIcon.setOnClickListener(OptionSection.this);
    return optionIcon;
}
 
源代码5 项目: LB-Launcher   文件: PagedViewWidget.java
public void applyFromAppWidgetProviderInfo(AppWidgetProviderInfo info,
        int maxWidth, int[] cellSpan, WidgetPreviewLoader loader) {
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

    mIsAppWidget = true;
    mInfo = info;
    final ImageView image = (ImageView) findViewById(R.id.widget_preview);
    if (maxWidth > -1) {
        image.setMaxWidth(maxWidth);
    }
    final TextView name = (TextView) findViewById(R.id.widget_name);
    name.setText(AppWidgetManagerCompat.getInstance(getContext()).loadLabel(info));
    final TextView dims = (TextView) findViewById(R.id.widget_dims);
    if (dims != null) {
        int hSpan = Math.min(cellSpan[0], (int) grid.numColumns);
        int vSpan = Math.min(cellSpan[1], (int) grid.numRows);
        dims.setText(String.format(mDimensionsFormatString, hSpan, vSpan));
    }
    mWidgetPreviewLoader = loader;
}
 
源代码6 项目: a   文件: MoDialogView.java
/**
 * 显示图像和文本
 */
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);
}
 
源代码7 项目: DevUtils   文件: ImageViewUtils.java
/**
 * 设置 ImageView 最大宽度
 * @param imageView ImageView
 * @param maxWidth  最大宽度
 * @return {@link ImageView}
 */
public static ImageView setMaxWidth(final ImageView imageView, final int maxWidth) {
    if (imageView != null) {
        imageView.setMaxWidth(maxWidth);
    }
    return imageView;
}
 
源代码8 项目: MyBookshelf   文件: MoDialogView.java
/**
 * 显示图像和文本
 */
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);
}
 
源代码9 项目: jellyfin-androidtv   文件: InfoLayoutHelper.java
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);
}
 
源代码10 项目: Android-Application-ZJB   文件: ZjbImageLoader.java
/**
 * 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);
}
 
源代码11 项目: 365browser   文件: PaymentRequestSection.java
private static ImageView createAndAddLogoView(ViewGroup parent, int startMargin) {
    ImageView view = new ImageView(parent.getContext());
    view.setMaxWidth(parent.getContext().getResources().getDimensionPixelSize(
            R.dimen.payments_section_logo_width));
    view.setAdjustViewBounds(true);

    // The logo has a pre-defined height and width.
    LayoutParams params =
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    ApiCompatibilityUtils.setMarginStart(params, startMargin);
    parent.addView(view, params);
    return view;
}
 
源代码12 项目: actor-platform   文件: SearchViewHacker.java
public static void disableMagIcon(SearchView searchView) {
    ImageView searchImageView = (ImageView) findView(searchView, "mSearchHintIcon");
    searchImageView.setMaxWidth(0);
    searchImageView.setImageBitmap(null);
    searchImageView.setVisibility(View.GONE);
    searchImageView.setAdjustViewBounds(true);
}
 
源代码13 项目: TGAReader   文件: TGABitmapViewerActivity.java
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;
}
 
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;
    }
}
 
源代码15 项目: commcare-android   文件: MediaLayout.java
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;
}
 
源代码16 项目: apigee-android-sdk   文件: MessageBoard.java
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);

		}

	}