List of usage examples for android.widget ImageView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.MusicObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/* w w w .j a v a2s .co m*/ LinearLayout container = new LinearLayout(context); container.setLayoutParams(CommonLayouts.FULL_WIDTH); container.setOrientation(LinearLayout.HORIZONTAL); container.setGravity(Gravity.CENTER); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.play); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); TextView valueTV = new TextView(context); valueTV.setText(asText(content)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT); valueTV.setPadding(4, 0, 0, 0); container.addView(imageView); container.addView(valueTV); frame.addView(container); }
From source file:com.roger.quickviewpage.ImageDetailActivity.java
public void setDot(int index) { dotGroup.removeAllViews();//from ww w .j a 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:com.android.inputmethod.keyboard.EmojiLayoutParams.java
public void setKeyProperties(ImageView ib) { final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ib.getLayoutParams(); lp.leftMargin = mKeyHorizontalGap / 2; lp.rightMargin = mKeyHorizontalGap / 2; ib.setLayoutParams(lp); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.PictureObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w w w. j a v a 2s . com byte[] raw = obj.getRaw(); if (raw == null) { Pair<JSONObject, byte[]> p = splitRaw(content); content = p.first; raw = p.second; } ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); imageView.setImageBitmap(BitmapFactory.decodeByteArray(raw, 0, raw.length)); // App.instance().objectImages.lazyLoadImage(raw.hashCode(), raw, imageView); frame.addView(imageView); }
From source file:com.aprz.easy_iosched.ui.widget.CustomRatingBar.java
/** * Creates ({@link ImageView}s) used to submit a rating using unfilled drawables and adds them to * the layout.// w ww .java 2s. c o m */ private void createRatingViews() { for (int i = 0; i < mMaxRating; i++) { ImageView imageView = new ImageView(getContext()); imageView.setLayoutParams( new android.view.ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); int tagValue = i + 1; imageView.setTag(tagValue); imageView.setContentDescription(getContext().getString(R.string.feedback_rating_value, tagValue)); imageView.setImageDrawable(mUnfilledDrawable); imageView.setOnClickListener(this); addView(imageView); } }
From source file:com.ccwant.photo.selector.activity.CCwantPhotoBrowserActivity.java
private void initListViews(String path) { ImageView img = new ImageView(this);// textView img.setBackgroundColor(0xff000000);/*w w w. j av a2 s.c o m*/ img.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); listViews.add(img);// view }
From source file:org.alfresco.mobile.android.application.fragments.activitystream.ActivityFeedFragment.java
@Override protected void prepareEmptyView(View ev, ImageView emptyImageView, TextView firstEmptyMessage, TextView secondEmptyMessage) {/* ww w . ja v a 2 s . c o m*/ emptyImageView.setLayoutParams(DisplayUtils.resizeLayout(getActivity(), 275, 275)); emptyImageView.setImageResource(R.drawable.ic_empty_activities); firstEmptyMessage.setText(R.string.activities_list_empty_title); secondEmptyMessage.setVisibility(View.VISIBLE); secondEmptyMessage.setText(R.string.activities_list_empty_description); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VideoObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*from w w w . j a va 2s .com*/ byte[] raw = obj.getRaw(); if (raw == null) { Pair<JSONObject, byte[]> p = splitRaw(content); content = p.first; raw = p.second; } LinearLayout inner = new LinearLayout(context); inner.setLayoutParams(CommonLayouts.FULL_WIDTH); inner.setOrientation(LinearLayout.HORIZONTAL); frame.addView(inner); ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); BitmapFactory bf = new BitmapFactory(); imageView.setImageBitmap(bf.decodeByteArray(raw, 0, raw.length)); inner.addView(imageView); ImageView iconView = new ImageView(context); iconView.setImageResource(R.drawable.play); iconView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); inner.addView(iconView); }
From source file:com.chrslee.csgopedia.app.CardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //Looks like he did this layout via code this is a layoutparams object //it defines the metrics and bounds of a specific view LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); //Creating a FrameLayout a FrameLayout is basically a empty container FrameLayout fl = new FrameLayout(context); fl.setLayoutParams(params);/* ww w . java2 s .c o m*/ //setting the params from above // First - image section //Building the imageview via code LayoutParams imgParams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); imgParams.gravity = Gravity.CENTER; //setting all centered ImageView iv = new ImageView(context); iv.setLayoutParams(imgParams); iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE); iv.setAdjustViewBounds(true); iv.setBackgroundResource(getActivity().getIntent().getExtras().getInt("iconID")); //seting the iconID as the image of this imageView // Second - prices section //final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources() // .getDisplayMetrics()); // //LinearLayout is another container it just take the //widgets inside it and display them in a linear order LinearLayout linLayout = new LinearLayout(context); linLayout.setOrientation(LinearLayout.VERTICAL); linLayout.setLayoutParams(params); linLayout.setGravity(Gravity.CENTER); // Get prices ConnectionDetector cd = new ConnectionDetector(context); //creating a connection detector to check for internet String query = getActivity().getIntent().getStringExtra("searchQuery"); //taking the name or whatever he pass from mainactivity from the searchquery arg TextView placeholder = new TextView(context); ///this is a textview for the name of the item if (cd.isConnectedToInternet()) {//if its connected to internet then if (query.equals("-1")) {//if the skin is regular he display is not for sale placeholder.setText("Regular skins are not for sale!"); linLayout.addView(placeholder); } else {//else he calls the scrappperAsyncTask with the query new ScraperAsyncTask(linLayout).execute(query); } } else {//if its not connected he display the message here placeholder.setText("Please connect to the Internet to view prices."); linLayout.addView(placeholder); } //here he defines which tab he is displaying, Now I see why he used the same fragment, //this is a bad practice, he created both widgets before but just displays one of them //for each case if its the first tab he display the image if its the second the prices if (position == 0) { fl.addView(iv); } else { fl.addView(linLayout); } //Then he returns the framelayout (container) to display it in the screen return fl; }
From source file:net.kourlas.voipms_sms.activities.NewConversationActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.new_conversation); Intent intent = getIntent();//from w ww . ja va 2s. co m String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && type != null && type.equals("text/plain")) { this.messageText = intent.getStringExtra(Intent.EXTRA_TEXT); } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); ViewCompat.setElevation(toolbar, getResources().getDimension(R.dimen.toolbar_elevation)); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setCustomView(R.layout.new_conversation_toolbar); actionBar.setDisplayShowCustomEnabled(true); } final Activity newConversationActivity = this; final NewConversationListViewAdapter newConversationListViewAdapter = new NewConversationListViewAdapter( this); if (actionBar != null) { SearchView searchView = (SearchView) actionBar.getCustomView().findViewById(R.id.search_view); searchView.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { String phoneNumber = newText.replaceAll("[^0-9]", ""); if (phoneNumber.equals("")) { newConversationListViewAdapter.hideTypedInItem(); } else { newConversationListViewAdapter.showTypedInItem(phoneNumber); } newConversationListViewAdapter.refresh(newText); return true; } }); searchView.requestFocus(); // Hide search icon ImageView searchMagIcon = (ImageView) searchView.findViewById(R.id.search_mag_icon); searchMagIcon.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); } final ListView listView = (ListView) findViewById(R.id.list); listView.setAdapter(newConversationListViewAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ContactItem contactItem = (ContactItem) newConversationListViewAdapter.getItem(position); String phoneNumber = contactItem.getPhoneNumber().replaceAll("[^0-9]", ""); Intent intent = new Intent(newConversationActivity, ConversationActivity.class); intent.putExtra(getString(R.string.conversation_extra_contact), phoneNumber); if (messageText != null) { intent.putExtra(getString(R.string.conversation_extra_message_text), messageText); } intent.putExtra(getString(R.string.conversation_extra_focus), true); startActivity(intent); } }); listView.setFastScrollEnabled(true); newConversationListViewAdapter.refresh(""); }