List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:com.nikola.despotoski.drawerlayoutedgetoggle.DrawerLayoutEdgeToggle.java
public DrawerLayoutEdgeToggle(Activity a, DrawerLayout l, int drawerOpen, int drawerClose, boolean keepShadowOnHandle, int drawerGravity) { if (drawerGravity != GravityCompat.END && drawerGravity != GravityCompat.START && drawerGravity != Gravity.LEFT && drawerGravity != Gravity.RIGHT) throw new IllegalArgumentException( "Use: GravityCompat.END, GravityCompat.START, Gravity.LEFT or Gravity.RIGHT for drawerGravity parameter"); mGravity = drawerGravity;/*from w ww .j a v a2s . com*/ mActivity = a; mDrawerLayout = l; mOpenDrawable = a.getResources().getDrawable(drawerOpen); mCloseDrawable = a.getResources().getDrawable(drawerClose); rootLayout = (FrameLayout) mActivity.findViewById(android.R.id.content); mHandle = new ImageView(a); final ViewTreeObserver viewTreeObserver = mHandle.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @SuppressLint("NewApi") @Override public void onGlobalLayout() { mDrawerLayout.measure(MeasureSpec.EXACTLY, MeasureSpec.EXACTLY); syncState(); removeOnGlobalLayoutListener(mHandle, this); } }); } mHandle.setOnClickListener(mHandleClickListenerInt); mHandle.setOnTouchListener(mHandleTouchListenerInt); mHandle.setSaveEnabled(true); mDrawerLayout.setOnTouchListener(mHandleTouchListenerInt); rootLayout.addView(mHandle, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, drawerGravity)); mKeepShadowOnHandle = keepShadowOnHandle; mCurrentDrawable = mCloseDrawable; }
From source file:com.murrayc.galaxyzoo.app.QuestionHelpFragment.java
private void addRowForAnswer(final Context context, final TableLayout tableLayout, final DecisionTree.Question question, final DecisionTree.BaseButton answer) { final TableRow row = new TableRow(context); final TableLayout.LayoutParams params = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT); params.setMargins(0, UiUtils.getPxForDpResource(context, R.dimen.standard_large_margin), 0, 0); tableLayout.addView(row, params);/*from w w w . j a v a 2 s . c om*/ final LinearLayout layoutVertical = new LinearLayout(context); layoutVertical.setOrientation(LinearLayout.VERTICAL); final TextView textViewAnswer = new AppCompatTextView(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textViewAnswer.setTextAppearance(R.style.TextAppearance_AppCompat_Subhead); } else { //noinspection deprecation textViewAnswer.setTextAppearance(context, R.style.TextAppearance_AppCompat_Subhead); } textViewAnswer.setText(answer.getText()); layoutVertical.addView(textViewAnswer, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); final LinearLayout layoutHorizontal = new LinearLayout(context); layoutHorizontal.setOrientation(LinearLayout.HORIZONTAL); final LinearLayout.LayoutParams paramsHorizontal = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); paramsHorizontal.setMargins(0, UiUtils.getPxForDpResource(context, R.dimen.standard_margin), 0, 0); layoutVertical.addView(layoutHorizontal, paramsHorizontal); final BitmapDrawable icon = getIcon(context, answer); final ImageView imageIcon = new ImageView(context); imageIcon.setImageDrawable(icon); layoutHorizontal.addView(imageIcon); final LinearLayout.LayoutParams paramsImage = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); // TODO: Use a custom FlowTable class to avoid items going off the right edge of the screen // when there are too many. final Singleton singleton = getSingleton(); for (int i = 0; i < answer.getExamplesCount(); i++) { final String iconName = answer.getExampleIconName(question.getId(), i); final BitmapDrawable iconExample = singleton.getIconDrawable(context, iconName); final ImageButton imageExample = new ImageButton(context); //Remove the space between the image and the outside of the button: imageExample.setPadding(0, 0, 0, 0); imageExample.setImageDrawable(iconExample); //Needed to make the image expand as a transition into the SubjectViewerActivity, //which uses the same name in fragment_subject.xml ViewCompat.setTransitionName(imageExample, getString(R.string.transition_subject_image)); //This requires API level 17: paramsImage.setMarginStart(getPxForDp(activity, MARGIN_MEDIUM_DP)); //imageExample.setLayoutParams(paramsImage); MarginLayoutParamsCompat.setMarginStart(paramsImage, UiUtils.getPxForDpResource(context, R.dimen.standard_large_margin)); final int answerIndex = i; imageExample.setOnClickListener(new View.OnClickListener() { public void onClick(final View v) { // Perform action on click onExampleImageClicked(v, answer, answerIndex); } }); layoutHorizontal.addView(imageExample, paramsImage); } row.addView(layoutVertical, new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppStateObj.java
public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from ww w .ja v a 2 s. co m // TODO: hack to show object history in app feeds JSONObject appState = getAppState(context, content); if (appState != null) { content = appState; } else { Log.e(TAG, "Missing inner content, probably because of format changes"); } boolean rendered = false; AppState ref = new AppState(content); String thumbnail = ref.getThumbnailImage(); if (thumbnail != null) { rendered = true; ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); App.instance().objectImages.lazyLoadImage(thumbnail.hashCode(), thumbnail, imageView); frame.addView(imageView); } thumbnail = ref.getThumbnailText(); if (thumbnail != null) { rendered = true; TextView valueTV = new TextView(context); valueTV.setText(thumbnail); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } thumbnail = ref.getThumbnailHtml(); if (thumbnail != null) { rendered = true; WebView webview = new WebView(context); webview.loadData(thumbnail, "text/html", "UTF-8"); webview.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); Object o = frame.getTag(R.id.object_entry); webview.setOnTouchListener(new WebViewClickListener(frame, (Integer) o)); frame.addView(webview); } if (!rendered) { String appName = content.optString(PACKAGE_NAME); if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } String text = "Welcome to " + appName + "!"; TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } }
From source file:com.javielinux.utils.SplitActionBarMenu.java
private void loadActionButtons(ArrayList<String> codes, final InfoTweet infoTweet, final long ownerColumn) { main_layout.removeAllViews();/* w ww . j av a 2 s . co m*/ boolean is_first = true; for (final String code : codes) { if (is_first) { is_first = false; } else { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0.0f); layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; ImageView imageView = new ImageView(activity); imageView.setBackgroundResource(R.drawable.action_bar_divider); imageView.setLayoutParams(layoutParams); main_layout.addView(imageView); } final InfoSubMenuTweet infoSubMenuTweet = new InfoSubMenuTweet(activity, code); ImageButton imageButton = new ImageButton(activity); imageButton.setBackgroundResource(R.drawable.default_background); int padding = (int) activity.getResources().getDimension(R.dimen.default_padding); imageButton.setPadding(padding, padding, padding, padding); imageButton.setImageResource(infoSubMenuTweet.getResDrawable()); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { hideSplitActionBarMenu(); TweetActions.execByCode(code, activity, ownerColumn, infoTweet, getFromFragment()); } }); imageButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Utils.showMessage(activity, activity.getResources().getString(infoSubMenuTweet.getResName())); return true; } }); main_layout.addView(imageButton); } }
From source file:nu.yona.app.ui.tour.YonaCarrouselActivity.java
/** * Set UI pager View Controller//from ww w. j a v a2 s .c o m */ private void setUiPageViewController() { dotsCount = mAdapter.getCount(); dots = new ImageView[dotsCount]; for (int i = 0; i < dotsCount; i++) { dots[i] = new ImageView(this); dots[i].setImageDrawable(ContextCompat.getDrawable(this, R.drawable.carrousel_nonselected_item)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(getResources().getInteger(R.integer.margin_pager_indicator), getResources().getInteger(R.integer.margin_pager_zero), getResources().getInteger(R.integer.margin_pager_indicator), getResources().getInteger(R.integer.margin_pager_zero)); pager_indicator.addView(dots[i], params); } displayFirstItem(0); }
From source file:com.githang.androidkit.app.IntroActivity.java
/** * //from w ww . j a v a 2s . c o m */ private void createContentView() { // ? mIntroResource = new IntroResource(); setIntroViews(mIntroResource); // RelativeLayout rootView = new RelativeLayout(this); rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // mViewPager = new ViewPager(this); RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); rootView.addView(mViewPager, pagerParams); // LinearLayout indicatorLayout = new LinearLayout(this); RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom; indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL); indicatorLayout.setLayoutParams(indicatorParams); indicatorLayout.setOrientation(LinearLayout.HORIZONTAL); // int indicatorCount = mIntroResource.views.size(); int padding = mIntroResource.indicatorImagePadding; mIndicator = new ArrayList<ImageView>(); for (int i = 0; i < indicatorCount; i++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); imageView.setPadding(padding, padding, padding, padding); imageView.setClickable(true); imageView.setOnClickListener(this); imageView.setImageResource(mIntroResource.indicatorNoSelectedId); imageView.setTag(i); mIndicator.add(imageView); indicatorLayout.addView(imageView, imageParams); } rootView.addView(indicatorLayout); setContentView(rootView); }
From source file:com.roger.quickviewpage.ImageDetailActivity.java
public void setDot(int index) { dotGroup.removeAllViews();/*from w ww . ja v a 2 s .co m*/ tips = new ImageView[index]; for (int i = 0; i < tips.length; i++) { ImageView imageView = new ImageView(ImageDetailActivity.this); imageView.setLayoutParams(new LayoutParams(5, 5)); tips[i] = imageView; if (i == 0) { tips[i].setBackgroundResource(R.drawable.news_diang); } else { tips[i].setBackgroundResource(R.drawable.news_diang_hover); } LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); layoutParams.leftMargin = 5; layoutParams.rightMargin = 5; dotGroup.addView(imageView, layoutParams); } }
From source file:mobisocial.musubi.service.WebRenderService.java
public static ImageView newLazyImageWeb(Context context, String html, int targetWidth, int targetHeight) { ImageView iv = new ImageView(context); //try the short cache if (sService != null) { SoftReference<Bitmap> srb = sService.mWebViewCache .get(new TByteArrayList(Util.sha256(html.getBytes()))); if (srb != null) { Bitmap b = srb.get();//from w ww . j a va 2 s.com if (b != null) { sService.setImageViewBitmapAndLayout(iv, b); return iv; } } } //set a default? iv.setImageBitmap(Bitmap.createBitmap(1, 1, Config.RGB_565)); WebRenderRequest req = new WebRenderRequest(); req.targetHeight = targetHeight; req.targetWidth = targetWidth; req.mDestionationView = iv; req.mHtml = html; if (sService != null) { sService.mWebViewClient.addItem(req); } else { sToProcess.add(req); } return iv; }
From source file:com.google.zxing.client.android.CaptureActivity.java
private void initConView() { mToolView = new ViewToolView(this, mData, toolListener); RelativeLayout.LayoutParams toolParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);//from ww w . j ava 2s. c om int top = (int) getResources().getDimension(EUExUtil.getResDimenID("plugin_uexscanner_tool_top")); int left = (int) getResources().getDimension(EUExUtil.getResDimenID("plugin_uexscanner_tool_left")); toolParams.setMargins(left, top, left, 0); mToolView.setId(1); mToolView.setLayoutParams(toolParams); mConRel.addView(mToolView); viewfinderView = new ViewfinderView(this, mData); RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); viewParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); viewfinderView.setLayoutParams(viewParams); mConRel.addView(viewfinderView); mGalleryPic = new ImageView(this); RelativeLayout.LayoutParams picParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); picParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); picParams.addRule(RelativeLayout.BELOW, 1); picParams.setMargins(left, top, left, top); mGalleryPic.setLayoutParams(picParams); mConRel.addView(mGalleryPic); mGalleryPic.setVisibility(View.GONE); mFailText = new TextView(this); RelativeLayout.LayoutParams failTextParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); failTextParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); mFailText.setLayoutParams(failTextParams); mFailText.setGravity(Gravity.CENTER); mFailText.setTextColor(Color.WHITE); mFailText.setTextSize(25); mConRel.addView(mFailText); mFailText.setVisibility(View.GONE); mFailText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mFailText.setVisibility(View.GONE); mGalleryPic.setVisibility(View.GONE); } }); }
From source file:com.bb.hbx.activitiy.InsurancePlanActivity.java
@Override public void initView() { setSupportActionBar(toolbar);// www .j av a2 s . co 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) { } }); }