List of usage examples for android.widget ImageView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:org.zywx.wbpalmstar.plugin.uexscrawl.PhotoScrawlActivity.java
private View getColorImageView(int color) { final ImageView imageView = new ImageView(this); int width = EUExUtil.dipToPixels(32); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, width); int margin = EUExUtil.dipToPixels(4); lp.leftMargin = margin;/*from w w w . j a va 2 s . co m*/ lp.rightMargin = margin; imageView.setLayoutParams(lp); imageView.setTag(color); GradientDrawable colorDrawable = new GradientDrawable(); colorDrawable.setColor(color); colorDrawable.setCornerRadius(8); if (Build.VERSION.SDK_INT < 16) { imageView.setBackgroundDrawable(colorDrawable); } else { imageView.setBackground(colorDrawable); } imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCurrnetColor = (int) imageView.getTag(); mScrawlImageView.setPaintColor(mCurrnetColor); mPreviewView.setColor(mCurrnetColor); } }); return imageView; }
From source file:com.bb.hbx.activitiy.InsurancePlanActivity.java
@Override public void initView() { setSupportActionBar(toolbar);//ww w. j a v a 2 s . c o m getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); insurerId = bundle.getString("insurerId"); serialId = bundle.getString("serialId"); city = bundle.getString("city"); licenseNo = bundle.getString("licenseNo"); insureName = bundle.getString("insureName"); driveName = bundle.getString("driveName"); idNo = bundle.getString("idNo"); mobile = bundle.getString("mobile"); carExtras = bundle.getString("carExtras"); carPrice = bundle.getString("carPrice"); modelCode = bundle.getString("modelCode"); int size = bundle.getInt("size", -1); for (int i = 0; i < size; i++) { //???? List<ComCarPropsBean.PlanListBean.SyxListBean> syxList = bundle.getParcelableArrayList("syxList" + i); for (int j = 0; j < syxList.size(); j++) { List<ComCarPropsBean.PlanListBean.SyxListBean.AmountListBeanXXX> amountList = bundle .getParcelableArrayList("amountList" + i + j); syxList.get(j).setAmountList(amountList); } //???? List<ComCarPropsBean.PlanListBean.JqxListBean> jqxList = bundle.getParcelableArrayList("jqxList" + i); for (int j = 0; j < jqxList.size(); j++) { List<ComCarPropsBean.PlanListBean.JqxListBean.AmountListBeanX> amountJqxList = bundle .getParcelableArrayList("amountJqxList" + i + j); jqxList.get(j).setAmountList(amountJqxList); } //???? List<ComCarPropsBean.PlanListBean.FjxListBean> fjxList = bundle.getParcelableArrayList("fjxList" + i); for (int j = 0; j < fjxList.size(); j++) { List<ComCarPropsBean.PlanListBean.FjxListBean.AmountListBean> amountFjxList = bundle .getParcelableArrayList("amountFjxList" + i + j); fjxList.get(j).setAmountList(amountFjxList); } //???? List<ComCarPropsBean.PlanListBean.QtxListBean> qtxList = bundle.getParcelableArrayList("qtxList" + i); for (int j = 0; j < qtxList.size(); j++) { List<ComCarPropsBean.PlanListBean.QtxListBean.AmountListBeanXX> amountQtxList = bundle .getParcelableArrayList("amountQtxList" + i + j); qtxList.get(j).setAmountList(amountQtxList); } ComCarPropsBean.PlanListBean planListBean = new ComCarPropsBean.PlanListBean(); // planListBean.setSyxList(syxList); planListBean.setFjxList(fjxList); planListBean.setQtxList(qtxList); planListBean.setJqxList(jqxList); planList.add(planListBean); } for (int i = 0; i < planList.size(); i++) { /*Item item = new BannerBean(); mlist.add(item);*/ ImageView dotView = new ImageView(mContext); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(10, 10); lp.leftMargin = 10; dotView.setLayoutParams(lp); dotView.setBackgroundResource(R.drawable.dot_selected); dotList.add(dotView); lin_add.addView(dotView); if (i == 0) {//---------2 dotList.get(i).setAlpha(1); } else { dotList.get(i).setAlpha(0.38f); } } //mCardAdapter = new CardPagerAdapter(this, mlist); mCardAdapter = new CardPagerAdapter(this, planList); mCardShadowTransformer = new ShadowTransformer(vp_tb, mCardAdapter); mCardShadowTransformer.setCanAlpha(true); mCardAdapter.setTransformer(mCardShadowTransformer); vp_tb.setAdapter(mCardAdapter); mCardAdapter.setPager(vp_tb); vp_tb.setPageTransformer(false, mCardShadowTransformer); mCardShadowTransformer.setAlpha(0.6f, true); mCardShadowTransformer.setScale(0.1f, true); //vp_tb.setCurrentItem(2);--------------- //vp_tb.setCurrentItem(10000 / 2 - 10000 / 2 % 3); if (planList.size() > 0) { vp_tb.setCurrentItem(0); getPlanPrice(0); } vp_tb.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { dotList.get(prePosition).setAlpha(0.38f); /*dotList.get(position%3).setAlpha(1); prePosition=position%3;*/ dotList.get(position).setAlpha(1); prePosition = position; //? getPlanPrice(position); } @Override public void onPageScrollStateChanged(int state) { } }); }
From source file:com.wll.main.widget.AbSlidingPlayView.java
/** * ./* w w w. j a v a 2 s .c om*/ */ public void creatIndex() { // ? // Bitmap bm=BitmapFactory.decodeResource(context.getResources(), R.color.black); // Bitmap bm2=BitmapFactory.decodeResource(context.getResources(), R.color.write); // displayImage=bm; // hideImage=bm2; navLinearLayout.removeAllViews(); mNavLayoutParent.setHorizontalGravity(navHorizontalGravity); navLinearLayout.setGravity(Gravity.CENTER); navLinearLayout.setVisibility(View.VISIBLE); count = mListViews.size(); navLayoutParams.setMargins(5, 5, 5, 5); for (int j = 0; j < count; j++) { ImageView imageView = new ImageView(context); imageView.setLayoutParams(navLayoutParams); if (j == 0) { imageView.setImageBitmap(displayImage); } else { imageView.setImageBitmap(hideImage); } navLinearLayout.addView(imageView, j); } }
From source file:com.yojiokisoft.yumekanow.activity.MakeCardActivity.java
/** * ???/* ww w .j av a 2 s . c o m*/ * * @param list */ private void setBackImageList(List<BackImageEntity> list) { int cnt = mBackImgContainer.getChildCount(); if (cnt > 0) { mBackImgContainer.removeAllViews(); } int w = MyResource.dip2Px(53); int h = MyResource.dip2Px(80); int p = MyResource.dip2Px(3); int size = list.size(); for (int i = 0; i < size; i++) { ImageView image = new ImageView(this); MyImage.setImageThum(image, list.get(i)); image.setLayoutParams(new LinearLayout.LayoutParams(w, h)); image.setPadding(p, p, p, p); image.setTag(i); image.setOnClickListener(mBackImageClicked); mBackImgContainer.addView(image); } }
From source file:com.gsma.rcs.ri.messaging.adapter.TalkCursorAdapter.java
private void bindRcsFileTransferOutView(View view, Cursor cursor) { RcsFileTransferOutViewHolder holder = (RcsFileTransferOutViewHolder) view.getTag(); holder.getTimestampText()/*from ww w . j a va2 s . c o m*/ .setText(DateUtils.getRelativeTimeSpanString(cursor.getLong(holder.getColumnTimestampIdx()), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE)); String mimeType = cursor.getString(holder.getColumnMimetypeIdx()); StringBuilder sb = new StringBuilder(cursor.getString(holder.getColumnFilenameIdx())); long filesize = cursor.getLong(holder.getColumnFilesizeIdx()); long transferred = cursor.getLong(holder.getColumnTransferredIdx()); final ImageView imageView = holder.getFileImageView(); imageView.setOnClickListener(null); imageView.setLayoutParams(mImageParamsDefault); imageView.setImageResource(R.drawable.ri_filetransfer_on); if (filesize != transferred) { holder.getProgressText() .setText(sb.append(" : ").append(Utils.getProgressLabel(transferred, filesize)).toString()); } else { holder.getProgressText().setText(sb.append(" (") .append(FileUtils.humanReadableByteCount(filesize, true)).append(")").toString()); } final Uri file = Uri.parse(cursor.getString(holder.getColumnContentIdx())); if (Utils.isImageType(mimeType)) { String filePath = FileUtils.getPath(mContext, file); Bitmap imageBitmap = null; if (filePath != null) { LruCache<String, BitmapCacheInfo> memoryCache = bitmapCache.getMemoryCache(); BitmapCacheInfo bitmapCacheInfo = memoryCache.get(filePath); if (bitmapCacheInfo == null) { ImageBitmapLoader loader = new ImageBitmapLoader(mContext, memoryCache, MAX_IMAGE_WIDTH, MAX_IMAGE_HEIGHT, new BitmapLoader.SetViewCallback() { @Override public void loadView(BitmapCacheInfo cacheInfo) { imageView.setImageBitmap(cacheInfo.getBitmap()); imageView.setLayoutParams(mImageParams); } }); loader.execute(filePath); } else { imageBitmap = bitmapCacheInfo.getBitmap(); } if (imageBitmap != null) { imageView.setImageBitmap(imageBitmap); imageView.setLayoutParams(mImageParams); } imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.showPicture(mActivity, file); } }); } } else if (Utils.isAudioType(mimeType)) { imageView.setImageResource(R.drawable.headphone); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.playAudio(mActivity, file); } }); } holder.getStatusText().setText(getRcsFileTransferStatus(cursor, holder)); boolean undeliveredExpiration = cursor.getInt(holder.getColumnExpiredDeliveryIdx()) == 1; holder.getStatusText().setCompoundDrawablesWithIntrinsicBounds( undeliveredExpiration ? R.drawable.chat_view_undelivered : 0, 0, 0, 0); }
From source file:com.gsma.rcs.ri.messaging.adapter.TalkCursorAdapter.java
private void bindRcsFileTransferInView(View view, Cursor cursor) { final RcsFileTransferInViewHolder holder = (RcsFileTransferInViewHolder) view.getTag(); holder.getTimestampText()/*w ww . j a v a2 s . com*/ .setText(DateUtils.getRelativeTimeSpanString(cursor.getLong(holder.getColumnTimestampIdx()), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE)); String mimeType = cursor.getString(holder.getColumnMimetypeIdx()); StringBuilder sb = new StringBuilder(cursor.getString(holder.getColumnFilenameIdx())); long filesize = cursor.getLong(holder.getColumnFilesizeIdx()); long transferred = cursor.getLong(holder.getColumnTransferredIdx()); final ImageView imageView = holder.getFileImageView(); imageView.setOnClickListener(null); imageView.setLayoutParams(mImageParamsDefault); imageView.setImageResource(R.drawable.ri_filetransfer_off); if (filesize != transferred) { holder.getProgressText() .setText(sb.append(" : ").append(Utils.getProgressLabel(transferred, filesize)).toString()); } else { imageView.setImageResource(R.drawable.ri_filetransfer_on); final Uri file = Uri.parse(cursor.getString(holder.getColumnContentIdx())); final RcsService.ReadStatus readStatus = RcsService.ReadStatus .valueOf(cursor.getInt(holder.getColumnReadStatusIdx())); final String id = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.ID)); if (Utils.isImageType(mimeType)) { final String filePath = FileUtils.getPath(mContext, file); if (filePath != null) { LruCache<String, BitmapCacheInfo> memoryCache = bitmapCache.getMemoryCache(); BitmapCacheInfo bitmapCacheInfo = memoryCache.get(filePath); if (bitmapCacheInfo == null) { ImageBitmapLoader loader = new ImageBitmapLoader(mContext, memoryCache, MAX_IMAGE_WIDTH, MAX_IMAGE_HEIGHT, new BitmapLoader.SetViewCallback() { @Override public void loadView(BitmapCacheInfo cacheInfo) { imageView.setImageBitmap(cacheInfo.getBitmap()); imageView.setLayoutParams(mImageParams); } }); loader.execute(filePath); } else { Bitmap imageBitmap = bitmapCacheInfo.getBitmap(); imageView.setImageBitmap(imageBitmap); imageView.setLayoutParams(mImageParams); } imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.showPicture(mActivity, file); markFileTransferAsRead(id, readStatus); } }); } } else if (Utils.isAudioType(mimeType)) { imageView.setImageResource(R.drawable.headphone); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.playAudio(mActivity, file); markFileTransferAsRead(id, readStatus); } }); } holder.getProgressText().setText(sb.append(" (") .append(FileUtils.humanReadableByteCount(filesize, true)).append(")").toString()); } holder.getStatusText().setText(getRcsFileTransferStatus(cursor, holder)); }
From source file:org.nla.tarotdroid.lib.ui.GameSetSynthesisFragment.java
/** * Refreshes the stats rows on the synthesis view. *//* ww w . j a va 2s.com*/ protected void refreshPlayerStatsRows() { // sort players List<Player> sortedPlayers = this.getGameSet().getPlayers().getPlayers(); Collections.sort(sortedPlayers, new PlayerScoreComparator()); // get general data sources IGameSetStatisticsComputer gameSetStatisticsComputer = GameSetStatisticsComputerFactory .GetGameSetStatisticsComputer(this.getGameSet(), "guava"); MapPlayersScores lastScores = this.getGameSet().getGameSetScores().getResultsAtLastGame(); Map<Player, Integer> leadingCount = gameSetStatisticsComputer.getLeadingCount(); Map<Player, Integer> leadingSuccesses = gameSetStatisticsComputer.getLeadingSuccessCount(); Map<Player, Integer> calledCount = gameSetStatisticsComputer.getCalledCount(); int minScoreEver = gameSetStatisticsComputer.getMinScoreEver(); int maxScoreEver = gameSetStatisticsComputer.getMaxScoreEver(); // format statistics lines for (int rank = 0; rank < sortedPlayers.size(); ++rank) { // get player specific data sources Player player = sortedPlayers.get(rank); int lastScore = lastScores == null ? 0 : lastScores.get(player); int successfulLeadingGamesCount = leadingSuccesses.get(player) == null ? 0 : leadingSuccesses.get(player).intValue(); int leadingGamesCount = leadingCount.get(player) == null ? 0 : leadingCount.get(player); int successRate = (int) (((double) successfulLeadingGamesCount) / ((double) leadingGamesCount) * 100.0); int minScoreForPlayer = gameSetStatisticsComputer.getMinScoreEverForPlayer(player); int maxScoreForPlayer = gameSetStatisticsComputer.getMaxScoreEverForPlayer(player); // get line widgets LinearLayout statRow = this.statsRows.get(rank + 1); //TextView statPlayerName = (TextView)statRow.findViewById(R.id.statPlayerName); TextView statScore = (TextView) statRow.findViewById(R.id.statScore); TextView statLeadingGamesCount = (TextView) statRow.findViewById(R.id.statLeadingGamesCount); TextView statSuccessfulGamesCount = (TextView) statRow.findViewById(R.id.statSuccessfulGamesCount); TextView statMinScore = (TextView) statRow.findViewById(R.id.statMinScore); TextView statMaxScore = (TextView) statRow.findViewById(R.id.statMaxScore); // Bitmap playerImage = null; // if (player.getPictureUri() != null && !player.getPictureUri().equals("")) { // playerImage = UIHelper.getPlayerImage(this.getActivity(), player); // } // // // // assign values to widgets // if (player.getFacebookId() != null) { // // player facebook image // ProfilePictureView pictureView = new ProfilePictureView(this.getActivity()); // pictureView.setProfileId(player.getFacebookId()); // pictureView.setPresetSize(ProfilePictureView.SMALL); // //pictureView.setOnClickListener(playerClickListener); // pictureView.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS); // statRow.removeViewAt(0); // statRow.addView(pictureView, 0); // } // else { // // WARNING: The properties below reference the style ScoreTextStyle, but we can't set a style at runtime. // TextView playerName = new TextView(this.getActivity()); // playerName.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1)); // playerName.setGravity(Gravity.CENTER); // playerName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); // playerName.setEllipsize(TruncateAt.END); // playerName.setSingleLine(); // playerName.setTextColor(Color.WHITE); // playerName.setTypeface(null, Typeface.BOLD); // playerName.setText(player.getName()); // //playerName.setBackgroundResource(R.drawable.border_player_white); // statRow.removeViewAt(0); // statRow.addView(playerName, 0); // } OnClickListener playerClickListener = new PlayerClickListener(player); // facebook picture if (player.getFacebookId() != null) { ProfilePictureView pictureView = new ProfilePictureView(this.getActivity()); pictureView.setProfileId(player.getFacebookId()); pictureView.setPresetSize(ProfilePictureView.SMALL); pictureView.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS); pictureView.setOnClickListener(playerClickListener); //this.addView(pictureView); statRow.removeViewAt(0); statRow.addView(pictureView, 0); } // contact picture else if (player.getPictureUri() != null && player.getPictureUri().toString().contains("content://com.android.contacts/contacts")) { Bitmap playerImage = UIHelper.getContactPicture(this.getActivity(), Uri.parse(player.getPictureUri()).getLastPathSegment()); ImageView imgPlayer = new ImageView(this.getActivity()); imgPlayer.setImageBitmap(playerImage); imgPlayer.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS); imgPlayer.setOnClickListener(playerClickListener); //this.addView(imgPlayer); statRow.removeViewAt(0); statRow.addView(imgPlayer, 0); } // no picture, only name else { TextView txtPlayer = new TextView(this.getActivity()); txtPlayer.setText(player.getName()); txtPlayer.setGravity(Gravity.CENTER); txtPlayer.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS); txtPlayer.setMinWidth(UIConstants.PLAYER_VIEW_WIDTH); txtPlayer.setHeight(UIConstants.PLAYER_VIEW_HEIGHT); txtPlayer.setBackgroundColor(Color.TRANSPARENT); txtPlayer.setTypeface(null, Typeface.BOLD); txtPlayer.setTextColor(Color.WHITE); txtPlayer.setSingleLine(); txtPlayer.setEllipsize(TruncateAt.END); txtPlayer.setOnClickListener(playerClickListener); //this.addView(txtPlayer); statRow.removeViewAt(0); statRow.addView(txtPlayer, 0); } statScore.setText(Integer.toString(lastScore)); statLeadingGamesCount.setText(Integer.toString(leadingGamesCount)); statSuccessfulGamesCount.setText( Integer.toString(successfulLeadingGamesCount) + " (" + Integer.toString(successRate) + "%)"); // display called game count if necessary if (this.getGameSet().getGameStyleType() == GameStyleType.Tarot5) { TextView statCalledGamesCount = (TextView) statRow.findViewById(R.id.statCalledGamesCount); statCalledGamesCount .setText(Integer.toString(calledCount.get(player) == null ? 0 : calledCount.get(player))); } statMinScore.setText(Integer.toString(minScoreForPlayer)); statMaxScore.setText(Integer.toString(maxScoreForPlayer)); statMinScore.setTextColor(Color.WHITE); statMaxScore.setTextColor(Color.WHITE); // color min score if lowest if (minScoreEver == minScoreForPlayer) { statMinScore.setTextColor(Color.YELLOW); } // color max score if highest if (maxScoreEver == maxScoreForPlayer) { statMaxScore.setTextColor(Color.GREEN); } } }
From source file:br.edu.ifpb.breath.slidingtabs.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int, int)}. *///from www . jav a 2 s . c om protected View createDefaultTabView(Context context, int type) { if (type == 0) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; } else { ImageView iconView = new ImageView(context); int iconSize = (int) (TAB_VIEW_ICON_SIZE_DIPS * getResources().getDisplayMetrics().density); int padding = (int) (TAB_VIEW_ICON_PADDING_DIPS * getResources().getDisplayMetrics().density); iconView.setLayoutParams(new LinearLayout.LayoutParams(iconSize + padding, iconSize + padding)); iconView.setScaleType(ImageView.ScaleType.FIT_CENTER); iconView.setPadding(padding, padding, padding, padding); return iconView; } }
From source file:com.xnote.lol.xnote.views.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); // calcluating horizontal padding for tabs so they fill the screen: int tabWidth = (int) Math.floor(((double) mScreenHorizontalWidth / adapter.getCount())); for (int i = 0; i < adapter.getCount(); i++) { ImageView tabView = new ImageView(getContext()); tabView.setImageDrawable(getPositiveIconDrawable(i)); tabView.setScaleType(ImageView.ScaleType.FIT_CENTER); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); tabView.setPadding(padding, padding, padding, padding); tabView.setLayoutParams(new LinearLayout.LayoutParams(tabWidth, ViewGroup.LayoutParams.WRAP_CONTENT)); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView);/*from w w w . j a v a 2 s. c om*/ } }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
private ImageView icon() { ImageView icon = new ImageView(context); LayoutParams layoutParams = new LayoutParams(UZCoreUtil.dipToPix(iconSize), UZCoreUtil.dipToPix(iconSize)); layoutParams.setMargins(UZCoreUtil.dipToPix(iconMarginLeft), UZCoreUtil.dipToPix(iconMarginTop), UZCoreUtil.dipToPix(iconMarginLeft), UZCoreUtil.dipToPix(iconMarginTop)); icon.setLayoutParams(layoutParams); if (getIcon() != null) { icon.setImageBitmap(getIcon());/*from w w w. ja v a2 s. c o m*/ } else { getImgShowUtil().display(icon, iconStr, getLoadCallBack()); } return icon; }