本文整理汇总了Java中android.widget.ImageView.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setPadding方法的具体用法?Java ImageView.setPadding怎么用?Java ImageView.setPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setPadding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MyViewHolder
import android.widget.ImageView; //导入方法依赖的package包/类
MyViewHolder(View view, PhotoLoaderInterface imageLoaderInterface, PhotoShowPicListener picOnClickListener) {
super(view);
this.picOnClickListener = picOnClickListener;
iv_pic = imageLoaderInterface.createImageView(view.getContext());
FrameLayout.LayoutParams pic_params = new FrameLayout.LayoutParams(icHeight, icHeight);
pic_params.setMargins(10, 10, 10, 10);
iv_pic.setLayoutParams(pic_params);
iv_del = new ImageView(view.getContext());
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.TOP | Gravity.END;
iv_del.setPadding(5, 5, 5, 5);
iv_del.setLayoutParams(layoutParams);
iv_pic.setId(R.id.iv_image_show_picker_pic);
iv_del.setId(R.id.iv_image_show_picker_del);
iv_pic.setOnClickListener(this);
iv_del.setOnClickListener(this);
}
示例2: buildCircles
import android.widget.ImageView; //导入方法依赖的package包/类
private void buildCircles(){
circles = LinearLayout.class.cast(findViewById(R.id.circles));
float scale = getResources().getDisplayMetrics().density;
int padding = (int) (5 * scale + 0.5f);
for(int i = 0 ; i < NUM_PAGES - 1 ; i++){
ImageView circle = new ImageView(this);
circle.setImageResource(R.drawable.ic_swipe_indicator_white_18dp);
circle.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
circle.setAdjustViewBounds(true);
circle.setPadding(padding, 0, padding, 0);
circles.addView(circle);
}
setIndicator(0);
}
示例3: getView
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView iv_emotion = new ImageView(context);
// 设置内边距
iv_emotion.setPadding(itemWidth/8, itemWidth/8, itemWidth/8, itemWidth/8);
LayoutParams params = new LayoutParams(itemWidth, itemWidth);
iv_emotion.setLayoutParams(params);
//判断是否为最后一个item
if(position == getCount() - 1) {
iv_emotion.setImageResource(R.drawable.compose_emotion_delete);
} else {
String emotionName = emotionNames.get(position);
iv_emotion.setImageResource(EmotionUtils.getImgByName(emotion_map_type,emotionName));
}
return iv_emotion;
}
示例4: setPageIndicator
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* 底部指示器资源图片
*
* @param page_indicatorId
*/
public ConvenientBanner setPageIndicator(int[] page_indicatorId) {
loPageTurningPoint.removeAllViews();
mPointViews.clear();
this.page_indicatorId = page_indicatorId;
if(mDatas==null)return this;
for (int count = 0; count < mDatas.size(); count++) {
// 翻页指示的点
ImageView pointView = new ImageView(getContext());
pointView.setPadding(15, 0, 15, 0);
if (mPointViews.isEmpty())
pointView.setImageResource(page_indicatorId[1]);
else
pointView.setImageResource(page_indicatorId[0]);
mPointViews.add(pointView);
loPageTurningPoint.addView(pointView);
}
pageChangeListener = new CBPageChangeListener(mPointViews,
page_indicatorId,this);
viewPager.setOnPageChangeListener(pageChangeListener);
return this;
}
示例5: instantiateItem
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imageView = new ImageView(context);
int padding = context.getResources().getDimensionPixelSize(R.dimen.small_margin);
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
Glide.with(context)
.load(Constants.IMAGE_BASE_PATH + pathList.get(position))
.animate(android.R.anim.fade_in)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.drawable.movie_placeholder)
.into(imageView);
((ViewPager) container).addView(imageView, 0);
return imageView;
}
示例6: onCreateOptionsMenu
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_user_profile, menu);
notification_item = (ImageView) menu.findItem(R.id.action_notification).getActionView();
messages_item = (ImageView) menu.findItem(R.id.action_message).getActionView();
activity_post = (ImageView) menu.findItem(R.id.action_status_post).getActionView();
if(mCurrentUser != null) {
menu.findItem(R.id.action_notification).setVisible(true);
menu.findItem(R.id.action_message).setVisible(true);
menu.findItem(R.id.action_status_post).setVisible(true);
notification_item.setImageDrawable(mCurrentUser.getNotifications() > 0?
ContextCompat.getDrawable(this, R.drawable.ic_notifications_active_white_24dp):
ContextCompat.getDrawable(this, R.drawable.ic_notifications_none_white_24dp)
);
notification_item.setPadding(0,0,20,0);
messages_item.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_mail_outline_white_24dp));
messages_item.setPadding(25,0,30,0);
activity_post.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_chat_bubble_outline_white_24dp));
activity_post.setPadding(25,0,15,0);
notification_item.setClickable(true);
activity_post.setClickable(true);
messages_item.setClickable(true);
notification_item.setOnClickListener(this);
messages_item.setOnClickListener(this);
activity_post.setOnClickListener(this);
showTutorial();
}
return true;
}
示例7: VideoListView
import android.widget.ImageView; //导入方法依赖的package包/类
public VideoListView(Context context, String text, int resId) {
super(context);
videoView = new TextView(context);
videoView.setText(text);
videoView.setId(VIDEOIDVIEW_ID);
videoView.setTextSize(15);
videoView.setTextColor(Color.BLACK);
videoView.setPadding(0, 10, 0, 0);
videoView.setSingleLine();
imageView = new ImageView(context);
imageView.setImageResource(resId);
imageView.setPadding(0, 10, 10, 0);
LayoutParams VideoLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
VideoLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
addView(videoView, VideoLayoutParams);
LayoutParams imageLayoutParams = new LayoutParams(ParamsUtil.dpToPx(context, 25), ParamsUtil.dpToPx(context, 25));
imageLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
imageLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
addView(imageView, imageLayoutParams);
setMinimumHeight(ParamsUtil.dpToPx(context, 48));
setPadding(10, 10, 10, 10);
}
示例8: createDayView
import android.widget.ImageView; //导入方法依赖的package包/类
private void createDayView(int tag, boolean selected) {
ImageView dayView = new ImageView(mContext);
dayView.setTag(tag);
LinearLayout.LayoutParams layoutParams =
new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT, layoutWeight);
dayView.setLayoutParams(layoutParams);
int padding = getDpFromPx(dayViewPadding);
dayView.setPadding(padding, padding, padding, padding);
dayView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mEditable) {
toggleSelection(v);
}
}
});
if (fullSize) {
if (tag == FRIDAY || tag == SATURDAY || tag == SUNDAY) {
row2.addView(dayView);
} else {
row1.addView(dayView);
}
} else {
addView(dayView);
}
setDaySelected(dayView, selected);
}
示例9: PhotoHolder
import android.widget.ImageView; //导入方法依赖的package包/类
PhotoHolder(View v) {
super(v);
layout = (RelativeLayout) v.findViewById(image_view_container);
imView = (ImageView) v.findViewById(image_id);
title = (TextView) v.findViewById(title_id);
layout.getLayoutParams().height = Defaults.IMAGE_HEIGHT;
if (isShapeCircle) {
int pad = Defaults.CIRCLE_PADDING;
imView.setPadding(pad, pad, pad, pad);
}
}
示例10: makeGallerySwitchBackGround
import android.widget.ImageView; //导入方法依赖的package包/类
private void makeGallerySwitchBackGround(LinearLayout gallerySwtichLayout, int count) {
int childCount = gallerySwtichLayout.getChildCount();
if (count > childCount) {
count -= childCount;
for (int i = 0; i < count; i++) {
ImageView itemImageView = new ImageView(getActivity());
itemImageView.setLayoutParams(new LayoutParams(-2, -2));
itemImageView.setImageResource(2130838158);
itemImageView.setPadding(5, 0, 5, 0);
gallerySwtichLayout.addView(itemImageView, childCount + i);
}
}
}
示例11: IndicatorLayout
import android.widget.ImageView; //导入方法依赖的package包/类
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
super(context);
mArrowImageView = new ImageView(context);
Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
mArrowImageView.setImageDrawable(arrowD);
final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
mArrowImageView.setPadding(padding, padding, padding, padding);
addView(mArrowImageView);
int inAnimResId, outAnimResId;
switch (mode) {
case PULL_FROM_END:
inAnimResId = R.anim.slide_in_from_bottom;
outAnimResId = R.anim.slide_out_to_bottom;
setBackgroundResource(R.drawable.indicator_bg_bottom);
// Rotate Arrow so it's pointing the correct way
mArrowImageView.setScaleType(ScaleType.MATRIX);
Matrix matrix = new Matrix();
matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
mArrowImageView.setImageMatrix(matrix);
break;
default:
case PULL_FROM_START:
inAnimResId = R.anim.slide_in_from_top;
outAnimResId = R.anim.slide_out_to_top;
setBackgroundResource(R.drawable.indicator_bg_top);
break;
}
mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
mInAnim.setAnimationListener(this);
mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
mOutAnim.setAnimationListener(this);
final Interpolator interpolator = new LinearInterpolator();
mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateAnimation.setInterpolator(interpolator);
mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
mRotateAnimation.setFillAfter(true);
mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
mResetRotateAnimation.setInterpolator(interpolator);
mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
mResetRotateAnimation.setFillAfter(true);
}
示例12: getAppThemeExpanded
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Manipulate the application theme with TRASLUCENT actionbar:
* Based on the corresponding theme (1-7) this method will:
* set the theme
* colorize the actionbar accordinlgy
* adjust the padding of the icon
* colorize (if >lollipop) the multitask
* colorize (if>KK) the statusbar
* <p/>
* this returns a drawable that corresponds to the actionbar background
* later to be manipulated by the corresponding activity
*
* @param context
*/
public static Drawable getAppThemeExpanded(final Activity context,
Drawable mActionBarBackgroundDrawable) {
int Theme = Integer.valueOf(PreferenceManager
.getDefaultSharedPreferences(context).getString(
PreferencesActivity.KEY_THEME, "3"));
mActionBarBackgroundDrawable = getThemeDrawable(context, Theme);
if (Theme == 4) {
context.setTheme(R.style.BlackTheme55);
} else if (Theme == 1 || Theme == 7) {
context.setTheme(R.style.CustomTheme55);
context.getActionBar().setSplitBackgroundDrawable(
mActionBarBackgroundDrawable);
context.getActionBar().setStackedBackgroundDrawable(
mActionBarBackgroundDrawable);
} else {
context.setTheme(R.style.ThunderMusic55);
context.getActionBar().setSplitBackgroundDrawable(
mActionBarBackgroundDrawable);
context.getActionBar().setStackedBackgroundDrawable(
mActionBarBackgroundDrawable);
}
ImageView view = (ImageView) context.findViewById(android.R.id.home);
int paddingRight;
if (context.getClass() == MediaPlaybackActivity.class) {
paddingRight = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 16, context.getResources()
.getDisplayMetrics());
} else {
paddingRight = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 24, context.getResources()
.getDisplayMetrics());
}
int paddingLeft = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 21, context.getResources()
.getDisplayMetrics());
view.setPadding(paddingLeft, 0, paddingRight, 0);
mActionBarBackgroundDrawable.setAlpha(0);
context.getActionBar().setIcon(R.drawable.ic_action_back);
context.getActionBar().setBackgroundDrawable(
mActionBarBackgroundDrawable);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Theme < 6)
context.setTaskDescription(new ActivityManager.TaskDescription(
context.getString(R.string.musicbrowserlabel),
BitmapFactory.decodeResource(context.getResources(),
R.drawable.app_music), context.getResources()
.getColor(getThemeColor(context, Theme))));
else
context.setTaskDescription(new ActivityManager.TaskDescription(
context.getString(R.string.musicbrowserlabel),
BitmapFactory.decodeResource(context.getResources(),
R.drawable.app_music), getThemeColor(context,
Theme)));
}
return mActionBarBackgroundDrawable;
}
示例13: getView
import android.widget.ImageView; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final DialogMenuItem item = contents.get(position);
LinearLayout ll_item = new LinearLayout(context);
ll_item.setOrientation(LinearLayout.HORIZONTAL);
ll_item.setGravity(Gravity.CENTER_VERTICAL);
ImageView iv_item = new ImageView(context);
iv_item.setPadding(0, 0, dp2px(15), 0);
ll_item.addView(iv_item);
TextView tv_item = new TextView(context);
tv_item.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv_item.setSingleLine(true);
tv_item.setTextColor(itemTextColor);
tv_item.setTextSize(TypedValue.COMPLEX_UNIT_SP, itemTextSize_SP);
ll_item.addView(tv_item);
float radius = dp2px(cornerRadius_DP);
if (isTitleShow) {
ll_item.setBackgroundDrawable((CornerUtils.listItemSelector(radius, Color.TRANSPARENT, itemPressColor,
position == contents.size() - 1)));
} else {
ll_item.setBackgroundDrawable(CornerUtils.listItemSelector(radius, Color.TRANSPARENT, itemPressColor,
contents.size(), position));
}
int left = item.resId == 0 ? dp2px(18) : dp2px(16);
int top = dp2px(10);
int right = 0;
int bottom = dp2px(10);
ll_item.setPadding(left + itemExtraLeft, top + itemExtraTop, right + itemExtraRight, bottom + itemExtraBottom);
iv_item.setImageResource(item.resId);
tv_item.setText(item.operName);
iv_item.setVisibility(item.resId == 0 ? View.GONE : View.VISIBLE);
return ll_item;
}
示例14: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.mipmap.ic_launcher);
// Faz a criação da lista de imagens
List<Integer> mListmages = ImageUtil.getImagesList();
final RelativeLayout relativeLayout = (RelativeLayout) this.findViewById(R.id.relative_photo_content_draw);
final LinearLayout content = (LinearLayout) this.findViewById(R.id.linear_horizontal_scroll_content);
// Itera o número de imagens
for (int i = 0; i < mListmages.size(); i++) {
// Obtém elemento de imagem
ImageView image = new ImageView(this);
// Substitui a imagem com a imagem sendo iterada
image.setImageBitmap(ImageUtil.decodeSampledBitmapFromResource(getResources(), mListmages.get(i), 70, 70));
image.setPadding(20,10,20,10);
// image.setLayoutParams(new LinearLayout.MarginLayoutParams(150, 150));
final int position = mListmages.get(i);
BitmapFactory.Options dimensions = new BitmapFactory.Options();
dimensions.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), mListmages.get(i), dimensions);
final int width = dimensions.outWidth;
final int height = dimensions.outHeight;
image.setOnClickListener(onClickImageOption(relativeLayout, position, width, height));
// Adiciona nova imagem
content.addView(image);
}
// Adiciona os elementos
this.mViewHolder.mImageTakePhoto = (ImageView) this.findViewById(R.id.image_take_photo);
this.mViewHolder.mImagePhoto = (ImageView) this.findViewById(R.id.image_photo);
this.mViewHolder.mImageInstagram = (ImageView) this.findViewById(R.id.image_instagram);
this.mViewHolder.mImageTwitter = (ImageView) this.findViewById(R.id.image_twitter);
this.mViewHolder.mImageFacebook = (ImageView) this.findViewById(R.id.image_facebook);
this.mViewHolder.mImageWahtsApp = (ImageView) this.findViewById(R.id.image_whatsapp);
this.mViewHolder.mButtonZoomIn = (ImageView) this.findViewById(R.id.image_zoom_in);
this.mViewHolder.mButtonZoomOut = (ImageView) this.findViewById(R.id.image_zoom_out);
this.mViewHolder.mButtonRotateLeft = (ImageView) this.findViewById(R.id.image_rotate_left);
this.mViewHolder.mButtonRotateRight = (ImageView) this.findViewById(R.id.image_rotate_right);
this.mViewHolder.mImageFinish = (ImageView) this.findViewById(R.id.image_finish);
this.mViewHolder.mImageRemove = (ImageView) this.findViewById(R.id.image_remove);
this.mViewHolder.mLinearSharePanel = (LinearLayout) this.findViewById(R.id.linear_share_panel);
this.mViewHolder.mLinearControlPanel = (LinearLayout) this.findViewById(R.id.linear_control_panel);
this.mViewHolder.mRelativePhotoContent = (RelativeLayout) this.findViewById(R.id.relative_photo_content_draw);
// Adicona evento aos elementos
this.setListeners();
// Incializa o SDK do facebook
FacebookSdk.sdkInitialize(getApplicationContext());
}
示例15: addResultListItem
import android.widget.ImageView; //导入方法依赖的package包/类
public void addResultListItem(String title, String value, LinearLayout netLayout) {
final float scale = activity.getResources().getDisplayMetrics().density;
final int leftRightItem = Helperfunctions.dpToPx(5, scale);
final int topBottomItem = Helperfunctions.dpToPx(5, scale);
final int leftRightDiv = Helperfunctions.dpToPx(0, scale);
final int topBottomDiv = Helperfunctions.dpToPx(0, scale);
final int heightDiv = Helperfunctions.dpToPx(1, scale);
final int topBottomImg = Helperfunctions.dpToPx(1, scale);
final LinearLayout netItemLayout = new LinearLayout(activity);
netItemLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
netItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem, topBottomItem);
netItemLayout.setGravity(Gravity.CENTER_VERTICAL);
final TextView itemTitle = new TextView(activity, null, R.style.listResultItemTitle);
itemTitle.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, 0.4f));
itemTitle.setWidth(0);
itemTitle.setGravity(Gravity.LEFT);
itemTitle.setText(title);
netItemLayout.addView(itemTitle);
final ImageView itemClassification = new ImageView(activity);
itemClassification.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.MATCH_PARENT, 0.1f));
itemClassification.setPadding(0, topBottomImg, 0, topBottomImg);
itemClassification.setImageDrawable(activity.getResources().getDrawable(
R.drawable.traffic_lights_none));
netItemLayout.addView(itemClassification);
final TextView itemValue = new TextView(activity, null, R.style.listResultItemValue);
itemValue.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, 0.5f));
itemValue.setWidth(0);
itemValue.setGravity(Gravity.LEFT);
itemValue.setText(value);
netItemLayout.addView(itemValue);
netLayout.addView(netItemLayout);
final View divider = new View(activity);
divider.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv,
1));
divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv);
divider.setBackgroundResource(R.drawable.bg_trans_light_10);
netLayout.addView(divider);
netLayout.invalidate();
}