List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothFixTabView.java
/** * Instantiates a new ab sliding smooth fix tab view. * * @param context the context/*from w ww . j a v a 2 s . c om*/ * @param attrs the attrs */ public ESSlidingSmoothFixTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //Tab? tabItemList = new ArrayList<TextView>(); tabItemTextList = new ArrayList<String>(); this.addView(mTabLayout, layoutParamsFW); //? mTabImg = new ImageView(context); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); //View? mViewPager = new ViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, layoutParamsFF); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { ESLogUtil.e(ESSlidingSmoothFixTabView.class, "AbSlidingSmoothTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = ESAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new ESFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothFixTabView.java
/** * Instantiates a new ab sliding smooth fix tab view. * * @param context the context// w w w. j a va 2 s . c o m * @param attrs the attrs */ public AbSlidingSmoothFixTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); //Tab? tabItemList = new ArrayList<TextView>(); tabItemTextList = new ArrayList<String>(); this.addView(mTabLayout, layoutParamsFW); //? mTabImg = new ImageView(context); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); //View? mViewPager = new ViewPager(context); //ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, layoutParamsFF); //?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbSlidingSmoothFixTabView.class, "AbSlidingSmoothTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }
From source file:com.airflo.FlightDetailFragment.java
/** * Method to build and add the View. It will consider preferences for * certain items, textsizes, and handle empty fields. *//*w w w. j av a2 s. c o m*/ public void addViews() { table.setColumnShrinkable(1, true); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(OnlyContext.getContext()); float detSize = Float.valueOf(sharedPrefs.getString("detailtextsize", "20")); boolean hideEmpty = sharedPrefs.getBoolean("detailListPrefEmpty", true); for (Identi identi : FlightData.identis.getIdentis()) { String prefKey = "detailListPref" + identi.getKey(); if (sharedPrefs.getBoolean(prefKey, true)) { if (hideEmpty) { if (mItem.getFromKey(identi.getKey()) == null) continue; if (mItem.getFromKey(identi.getKey()).equals("")) continue; } if (identi.getKey().equals("tag")) { if (mItem.getFromKey(identi.getKey()).length() > 0) { LinearLayout lnn = (LinearLayout) rootView.findViewById(R.id.LinearAdditionLayout); String[] tags = mItem.getFromKey(identi.getKey()).split(";"); for (String tag : tags) { if (tag.equals("off-field")) tag = "off_field"; int resID = getResources().getIdentifier(tag, "drawable", "com.airflo"); ImageView img = new ImageView(getActivity()); img.setImageResource(resID); img.setPadding(8, 14, 8, 0); lnn.addView(img); } } } else { TableRow row = new TableRow(getActivity()); header = new TextView(getActivity()); header.setSingleLine(); header.setTextSize(detSize); header.setText(identi.getStringRep()); header.setPadding(6, 4, 10, 4); row.addView(header); cell = new TextView(getActivity()); cell.setSingleLine(false); cell.setTextSize(detSize); cell.setText(mItem.getFromKey(identi.getKey())); cell.setPadding(6, 4, 6, 4); row.addView(cell); table.addView(row); } } } }
From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.RecyclerViewFastIndexer.java
protected void init(Context context) { if (isInitialized) return;//from ww w . j ava2s . c o m isInitialized = true; setOrientation(HORIZONTAL); setClipChildren(false); setWillNotDraw(false); bubble = new TextView(context); bubble.setTextColor(Color.WHITE); bubble.setTextSize(48); GradientDrawable bubbleDrawable = new GradientDrawable(); bubbleDrawable.setColor(0xFFce891e); bubbleDrawable.setSize(getCustomSize(88), getCustomSize(88)); bubbleDrawable.setCornerRadii(new float[] { getCustomSize(44), getCustomSize(44), getCustomSize(44), getCustomSize(44), 0, 0, getCustomSize(44), getCustomSize(44) }); bubble.setBackgroundDrawable(bubbleDrawable); //bubble.setBackgroundResource(R.drawable.recycler_view_fast_scroller__bubble); bubble.setGravity(Gravity.CENTER); LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.RIGHT | Gravity.END; addView(bubble, params); if (bubble != null) bubble.setVisibility(INVISIBLE); handle = new ImageView(context); //handle.setBackgroundResource(R.drawable.recycler_view_fast_scroller__handle); GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setSize(getCustomSize(4), getCustomSize(35)); drawable.setColor(0xFFce891e); drawable.setCornerRadius(getCustomSize(5)); GradientDrawable drawable2 = new GradientDrawable(); drawable2.setShape(GradientDrawable.RECTANGLE); drawable2.setSize(getCustomSize(4), getCustomSize(35)); drawable2.setColor(0xFFf3a124); drawable2.setCornerRadius(getCustomSize(5)); StateListDrawable states = new StateListDrawable(); states.addState(new int[] { android.R.attr.state_selected }, drawable); states.addState(new int[] {}, drawable2); handle.setBackgroundDrawable(states); LayoutParams params2 = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); int dimension = getCustomSize(3); int doubleDimension = dimension * 2; params2.leftMargin = doubleDimension; params2.rightMargin = doubleDimension; handle.setPadding(dimension, 0, dimension, 0); handle.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { v.setBackgroundColor(Color.parseColor("#00891e")); } else { v.setBackgroundColor(Color.parseColor("#44891e")); } } }); addView(handle, params2); }
From source file:com.wms.opensource.ezchannel.activity.VideoListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (layout != null) { // We need to remove layout from its parent first. Otherwise, adding layout to different viewgroup will result in error ViewGroup parent = (ViewGroup) layout.getParent(); parent.removeView(layout);//from w ww . j av a2s .c om return layout; } if (listView == null) { layout = new RelativeLayout(getActivity()); listView = new ListView(getActivity()); layout.addView(listView); imageViewStandardThumbnail = new ImageView(getActivity()); RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imageViewParams.addRule(RelativeLayout.CENTER_IN_PARENT); imageViewStandardThumbnail.setLayoutParams(imageViewParams); imageViewStandardThumbnail.setVisibility(View.INVISIBLE); imageViewStandardThumbnail.setBackgroundResource(R.drawable.border); imageViewStandardThumbnail.setOnClickListener(new ImageView.OnClickListener() { @Override public void onClick(View v) { // Dismiss the image view v.setVisibility(View.INVISIBLE); Animation myAnim = AnimationUtils.loadAnimation(VideoListFragment.this.getActivity(), R.anim.fadeout); v.startAnimation(myAnim); } }); layout.addView(imageViewStandardThumbnail); progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleLarge); // Center a view in relative layout RelativeLayout.LayoutParams progressBarBarams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); progressBarBarams.addRule(RelativeLayout.CENTER_IN_PARENT); progressBar.setLayoutParams(progressBarBarams); progressBar.setVisibility(View.INVISIBLE); layout.addView(progressBar); // Before reloading videos, display videos if they have been saved before. String videosFilePath = ""; if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) { videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameProvider.getYouTubePlaylistPersistFileName(playlistID, page); } else { videosFilePath = StorageUtil.getTempDirectory(this.getActivity()) + "/" + PersistFileNameProvider .getYouTubeSearchListPersistFileName(getActivity().getString(R.string.appID), page); } boolean videosFileExists = FileUtil.fileExist(videosFilePath); if (videosFileExists) { loadPlaylistVideosFromLocalTask = new LoadCachedVideosTask(getActivity(), loadVideosHandler, VideoListFragmentActivity.videoSource, progressBar, playlistID, page); loadPlaylistVideosFromLocalTask.execute(); } else { NetworkStatus networkStatus = NetworkUtil.getNetworkStatus(getActivity()); if (networkStatus.equals(NetworkStatus.WIFI_CONNECTED) || networkStatus.equals(NetworkStatus.MOBILE_CONNECTED)) { String pageToken = page == 1 ? null : VideoListFragmentActivity.pageTokens.get(page - 1); // page start from 1 if (VideoListFragmentActivity.videoSource == YouTubeVideoSource.Playlist) { loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler, YouTubeVideoSource.Playlist, playlistID, pageToken, page); } else { loadVideosTask = new LoadVideosTask(getActivity(), loadVideosHandler, YouTubeVideoSource.Search, queryTerm, pageToken, page); } loadVideosTask.execute(); } else { Toast.makeText(getActivity(), getString(R.string.noNetworkAvailable), Toast.LENGTH_LONG).show(); } } } return layout; }
From source file:com.itsronald.widget.IndicatorDotPathView.java
IndicatorDotPathView(@NonNull Context context) { super(context); final float scale = context.getResources().getDisplayMetrics().density; this.dotPadding = (int) (DEFAULT_DOT_PADDING_DIP * scale + 0.5); this.dotRadius = (int) (DEFAULT_DOT_RADIUS_DIP * scale + 0.5); this.startDot = new IndicatorDotView(context); this.endDot = new IndicatorDotView(context); this.startPathSegment = new DotPathSegment(context); this.endPathSegment = new DotPathSegment(context); this.centerSegment = new ImageView(context); this.centerSegment.setImageDrawable(centerPathShape); init(DEFAULT_DOT_COLOR);// w w w.j a va 2 s. c om }
From source file:com.common.android.lib.controls.view.indicator.IconPageIndicator.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();//from ww w .jav a2 s.c om IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter(); int count = iconAdapter.getCount(); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.setMargins(15, 0, 0, 0); view.setImageResource(iconAdapter.getIconResId(i)); view.setLayoutParams(lp); mIconsLayout.addView(view); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }
From source file:com.ccwant.photo.selector.activity.CCwantPhotoBrowserActivity.java
private void initListViews(String path) { ImageView img = new ImageView(this);// textView img.setBackgroundColor(0xff000000);//from ww w . j a v a 2s . co m img.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); listViews.add(img);// view }
From source file:org.gots.seed.view.SeedWidgetLong.java
@SuppressWarnings("deprecation") private void setupView() { if (mSeed == null) return;//from w w w .j a v a 2s . c o m int familyImageRessource = 0; if (mSeed.getFamily() != null) familyImageRessource = getResources() .getIdentifier("org.gots:drawable/family_" + mSeed.getFamily().toLowerCase(), null, null); if (familyImageRessource != 0) setBackgroundResource(familyImageRessource); else { int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.family_unknown)); } else { setBackground(mContext.getResources().getDrawable(R.drawable.family_unknown)); } } SeedWidget seedWidget = (SeedWidget) findViewById(R.id.idSeedWidget2); seedWidget.setSeed(mSeed); TextView seedSpecie = (TextView) findViewById(R.id.IdSeedSpecie); seedSpecie.setText(SeedUtil.translateSpecie(mContext, mSeed)); if (GotsPreferences.DEBUG) seedSpecie.setText("(" + mSeed.getSeedId() + ")" + SeedUtil.translateSpecie(mContext, mSeed)); TextView seedVariety = (TextView) findViewById(R.id.IdSeedVariety); seedVariety.setText(mSeed.getVariety()); PlanningWidget planningSow = (PlanningWidget) findViewById(R.id.IdSeedSowingPlanning); planningSow.setAdapter(new PlanningSowAdapter(mSeed)); // PlanningWidget planningHarvest = (PlanningWidget) findViewById(R.id.IdSeedHarvestPlanning); planningHarvest.setAdapter(new PlanningHarvestAdapter(mSeed)); LinearLayout stock = (LinearLayout) findViewById(R.id.idSeedStock); stock.removeAllViews(); for (int i = 0; i < mSeed.getNbSachet(); i++) { ImageView seedbag = new ImageView(mContext); seedbag.setImageDrawable(mContext.getResources().getDrawable(R.drawable.seed_bag)); // seedbag.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_planning_sow)); LayoutParams params = new LinearLayout.LayoutParams(30, 30); seedbag.setLayoutParams(params); stock.addView(seedbag, i); } if (mSeed.getLanguage() != null && !"".equals(mSeed.getLanguage())) { ImageView flag = (ImageView) findViewById(R.id.IdSeedLanguage); int flagRessource = getResources() .getIdentifier("org.gots:drawable/" + mSeed.getLanguage().toLowerCase(), null, null); flag.setImageResource(flagRessource); } likeCount = (TextView) findViewById(R.id.textSeedLike); like = (ImageView) findViewById(R.id.ImageSeedLike); displayLikeStatus(mSeed.getLikeStatus()); if (mSeed.getUUID() == null) like.setVisibility(View.GONE); like.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AsyncTask<Void, Void, LikeStatus>() { GotsException exception = null; @Override protected LikeStatus doInBackground(Void... params) { GotsSeedManager manager = GotsSeedManager.getInstance().initIfNew(mContext); try { return manager.like(mSeed, mSeed.getLikeStatus().getUserLikeStatus() == 1); } catch (GotsException e) { exception = e; return null; } catch (Exception e) { Log.e(getClass().getName(), "" + e.getMessage(), e); return null; } } protected void onPostExecute(LikeStatus result) { if (result == null && exception != null) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); // set title alertDialogBuilder.setTitle(exception.getMessage()); alertDialogBuilder.setMessage(exception.getMessageDescription()).setCancelable(false) .setPositiveButton(mContext.getResources().getString(R.string.login_connect), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Intent loginIntent = new Intent(mContext, LoginDialogFragment.class); // mContext.startActivity(loginIntent); LoginDialogFragment dialogFragment = new LoginDialogFragment(); dialogFragment.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog); dialogFragment.show(((FragmentActivity) mContext) .getSupportFragmentManager(), ""); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); return; } mSeed.setLikeStatus(result); displayLikeStatus(result); mContext.sendBroadcast(new Intent(BroadCastMessages.SEED_DISPLAYLIST)); }; }.execute(); } }); }
From source file:edu.rowan.app.carousel.CarouselFeature.java
public void loadImage() { carouselView = new RelativeLayout(context); imageView = new ImageView(context); Bitmap cachedImage = aq.getCachedImage(imageURL); if (cachedImage != null) { // System.out.println("Image was cached!"); imageView.setImageBitmap(cachedImage); carouselView.addView(imageView); setupView();/*from w w w . j a va2 s . c o m*/ listener.doneLoading(this); } else { // Aquery download and cache image aq.id(imageView).image(imageURL, true, true, 0, 0, new BitmapAjaxCallback() { @Override // set imageview to loaded bitmap and tell listener we're done loading public void callback(String url, ImageView iv, Bitmap bm, AjaxStatus status) { iv.setImageBitmap(bm); carouselView.addView(iv); setupView(); listener.doneLoading(CarouselFeature.this); } }); } }