本文整理汇总了C#中ImageView.SetImageDrawable方法的典型用法代码示例。如果您正苦于以下问题:C# ImageView.SetImageDrawable方法的具体用法?C# ImageView.SetImageDrawable怎么用?C# ImageView.SetImageDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView.SetImageDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawCode
static void DrawCode(string code, ImageView barcode)
{
var writer = new BarcodeWriter
{
Format = BarcodeFormat.CODE_39,
Options = new EncodingOptions
{
Height = 200,
Width = 600
}
};
var bitmap = writer.Write(code);
Drawable img = new BitmapDrawable(bitmap);
barcode.SetImageDrawable(img);
}
示例2: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.ExhibitorDetailsScreen);
var id = Intent.GetIntExtra("UserGroupID", -1);
if (id >= 0) {
usergroup = BL.Managers.UserGroupManager.GetUserGroup(id);
if (usergroup != null) {
FindViewById<TextView>(Resource.Id.NameTextView).Text = usergroup.Name;
//FindViewById<TextView>(Resource.Id.CountryTextView).Text = usergroup.FormattedCityCountry;
//FindViewById<TextView>(Resource.Id.LocationTextView).Text = usergroup.Locations;
if (!String.IsNullOrEmpty(usergroup.Overview))
FindViewById<TextView>(Resource.Id.DescriptionTextView).Text = usergroup.Overview;
else
FindViewById<TextView>(Resource.Id.DescriptionTextView).Text = "No background information available.";
// now do the image
imageview = FindViewById<ImageView>(Resource.Id.ExhibitorImageView);
var uri = new Uri(usergroup.ImageUrl);
Console.WriteLine("usergroup.ImageUrl " + usergroup.ImageUrl);
try {
var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, this);
if (drawable != null)
imageview.SetImageDrawable(drawable);
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
}
} else { // shouldn't happen...
FindViewById<TextView>(Resource.Id.NameTextView).Text = "UserGroup not found: " + id;
}
}
}
示例3: IndicatorLayout
public IndicatorLayout(Context context, Mode mode)
: base(context)
{
//super(context);
mArrowImageView = new ImageView(context);
Drawable arrowD = Resources.GetDrawable(Resource.Drawable.indicator_arrow);
mArrowImageView.SetImageDrawable(arrowD);
int padding = Resources.GetDimensionPixelSize(Resource.Dimension.indicator_internal_padding);
mArrowImageView.SetPadding(padding, padding, padding, padding);
AddView(mArrowImageView);
int inAnimResId, outAnimResId;
switch (mode)
{
case Mode.PULL_FROM_END:
inAnimResId = Resource.Animation.slide_in_from_bottom;
outAnimResId = Resource.Animation.slide_out_to_bottom;
SetBackgroundResource(Resource.Drawable.indicator_bg_bottom);
// Rotate Arrow so it's pointing the correct way
mArrowImageView.SetScaleType(Android.Widget.ImageView.ScaleType.Matrix);
Matrix matrix = new Matrix();
matrix.SetRotate(180f, arrowD.IntrinsicWidth / 2f, arrowD.IntrinsicHeight / 2f);
mArrowImageView.ImageMatrix = matrix;
break;
default:
case Mode.PULL_FROM_START:
inAnimResId = Resource.Animation.slide_in_from_top;
outAnimResId = Resource.Animation.slide_out_to_top;
SetBackgroundResource(Resource.Drawable.indicator_bg_top);
break;
}
mInAnim = AnimationUtils.LoadAnimation(context, inAnimResId);
mInAnim.SetAnimationListener(this);
mOutAnim = AnimationUtils.LoadAnimation(context, outAnimResId);
mOutAnim.SetAnimationListener(this);
IInterpolator interpolator = new LinearInterpolator();
//mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);
mRotateAnimation = new RotateAnimation(0, -180, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f);
mRotateAnimation.Interpolator = interpolator;
mRotateAnimation.Duration = DEFAULT_ROTATION_ANIMATION_DURATION;
mRotateAnimation.FillAfter = true;
mResetRotateAnimation = new RotateAnimation(-180, 0, Dimension.RelativeToSelf, 0.5f,
Dimension.RelativeToSelf, 0.5f);
mResetRotateAnimation.Interpolator = interpolator;
mResetRotateAnimation.Duration = DEFAULT_ROTATION_ANIMATION_DURATION;
mResetRotateAnimation.FillAfter = true;
}
示例4: OnCreateView
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
if (container == null) {
// Currently in a layout without a container, so no reason to create our view.
return null;
}
var view = inflater.Inflate(Resource.Layout.speaker_screen, container, false);
var speaker = EvolveData.SpeakerData [ShownSpeakerIndex];
headshotImageView = view.FindViewById<ImageView> (Resource.Id.headshotImageView);
var headshot = GetHeadShot (speaker.HeadshotUrl);
headshotImageView.SetImageDrawable (headshot);
speakerNameTextView = view.FindViewById<TextView> (Resource.Id.speakerNameTextView);
speakerNameTextView.Text = speaker.Name;
companyNameTextView = view.FindViewById<TextView> (Resource.Id.companyNameTextView);
companyNameTextView.Text = speaker.Company;
twitterHandleView = view.FindViewById<TextView> (Resource.Id.twitterTextView);
twitterHandleView.Text = "@" + speaker.TwitterHandle;
return view;
}
示例5: SetSolvedStateForQuiz
void SetSolvedStateForQuiz (ImageView solvedState, int position)
{
var context = solvedState.Context;
Drawable tintedImage;
tintedImage = (category.IsSolvedCorrectly ((Quiz)GetItem (position))) ? GetSuccessIcon (context) : GetFailedIcon (context);
solvedState.SetImageDrawable (tintedImage);
}
示例6: Download
public static void Download(string url, ImageView imageView, Resources resources, Bitmap placeholder)
{
if(CancelPotentialDownload(url, imageView))
{
var task = new DownloadImageTask(imageView);
var drawable = new AsyncDrawable(resources, placeholder, task);
imageView.SetImageDrawable(drawable);
task.Execute(url);
}
}
示例7: CleanImageView
public static void CleanImageView(ImageView imageView)
{
if (imageView == null || imageView.Drawable == null || imageView.Drawable.GetType() != typeof(BitmapDrawable))
return;
// Clean up the view's image for the sake of memory
BitmapDrawable b = (BitmapDrawable)imageView.Drawable;
b.Bitmap.Recycle();
imageView.SetImageDrawable(null);
}
示例8: SetCategoryIcon
void SetCategoryIcon (Category category, ImageView icon)
{
var categoryImageResource = resources.GetIdentifier (IconCategory + category.Id, Drawable, packageName);
var solved = category.Solved;
if (solved) {
var solvedIcon = LoadSolvedIcon (category, categoryImageResource);
icon.SetImageDrawable (solvedIcon);
} else {
icon.SetImageResource (categoryImageResource);
}
}
示例9: LoadMap
internal async void LoadMap (GeoPoint point, FavoriteView view, ImageView mapView, long version)
{
var url = MakeMapUrl (point);
var bmp = await LoadInternal (url, MapCache);
if (bmp != null && view.VersionNumber == version) {
mapView.AlphaAnimate (0, duration: 150, endAction: () => {
mapView.SetImageDrawable (new RoundCornerDrawable (bmp));
mapView.AlphaAnimate (1, duration: 250);
});
}
}
示例10: LoadStreetView
internal async void LoadStreetView (LatLng location, HubwayMapFragment frag, long stationID, ProgressBar spinner, ImageView img)
{
var url = MakeStreetViewUrl (img, location);
var bmp = await LoadInternal (url, StreetViewCache);
if (bmp != null && frag.CurrentShownId == stationID) {
img.SetImageDrawable (new RoundCornerDrawable (bmp, cornerRadius: 3));
img.Visibility = Android.Views.ViewStates.Visible;
spinner.AlphaAnimate (0, duration: 250);
img.AlphaAnimate (1, duration: 250);
}
}
示例11: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
mImageView = new ImageView(Activity);
string path = Arguments.GetString(EXTRA_IMAGE_PATH);
float rotation = Arguments.GetFloat(EXTRA_IMAGE_ROTATION);
BitmapDrawable image = PictureUtils.GetScaledDrawable(Activity, path);
mImageView.SetImageDrawable(image);
mImageView.Rotation = rotation;
return mImageView;
}
示例12: SetImage
protected virtual void SetImage(ImageView imageView, int id)
{
var context = imageView.Context;
Drawable drawable;
if(Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
drawable = context?.Resources?.GetDrawable(id, context.Theme);
else
drawable = context?.Resources?.GetDrawable(id);
if(drawable != null)
imageView.SetImageDrawable(drawable);
}
示例13: OnCreate
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
ImageView imageView = new ImageView (this);
// Set the background color to white
imageView.SetBackgroundColor (Android.Graphics.Color.White);
// Parse the SVG file from the resource
SVG svg = SVGParser.GetSVGFromAsset (Assets, "svg/gradients.svg");
// Get a drawable from the parsed SVG and set it as the drawable for the ImageView
imageView.SetImageDrawable (svg.CreatePictureDrawable ());
// Set the ImageView as the content view for the Activity
SetContentView (imageView);
}
示例14: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.TweetDetailsScreen);
var id = Intent.GetIntExtra("TweetID", -1);
if (id >= 0) {
tweet = BL.Managers.TwitterFeedManager.GetTweet(id);
if (tweet != null) {
FindViewById<TextView>(Resource.Id.NameTextView).Text = tweet.RealName;
FindViewById<TextView>(Resource.Id.NameTextView).Click += (object sender, EventArgs e) => {
Intent browserIntent = new Intent(Intent.ActionView, global::Android.Net.Uri.Parse(tweet.AuthorUrl));
StartActivity(browserIntent);
};
FindViewById<TextView>(Resource.Id.HandleTextView).Text = tweet.FormattedAuthor;
FindViewById<TextView>(Resource.Id.HandleTextView).Click +=(object sender, EventArgs e) => {
Intent browserIntent = new Intent(Intent.ActionView, global::Android.Net.Uri.Parse(tweet.AuthorUrl));
StartActivity(browserIntent);
};
FindViewById<TextView>(Resource.Id.TimeTextView).Text = tweet.FormattedTime;
// ugh - LoadData() method has problems when html contains a %
// http://code.google.com/p/android/issues/detail?id=1733
// http://code.google.com/p/android/issues/detail?id=4401
FindViewById<WebView>(Resource.Id.ContentWebView).LoadDataWithBaseURL(null,
"<html><body>" + tweet.Content + "</body></html>", @"text/html", "utf-8", null);
imageview = FindViewById<ImageView> (Resource.Id.TwitterImageView);
var uri = new Uri(tweet.ImageUrl);
Console.WriteLine("speaker.ImageUrl " + tweet.ImageUrl);
try {
var drawable = MonoTouch.Dialog.Utilities.ImageLoader.DefaultRequestImage(uri, this);
if (drawable != null)
imageview.SetImageDrawable(drawable);
} catch (Exception ex) {
Log.Debug("TWITTER", ex.ToString());
}
} else { // shouldn't happen...
FindViewById<TextView>(Resource.Id.TitleTextView).Text = "Tweet not found: " + id;
}
}
}
示例15: OnCreateView
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.HomeActivity, container, false);
toolbarLayout = view.FindViewById(Resource.Id.toolbarLayout);
((TextView)toolbarLayout.FindViewById(Resource.Id.toolbar_titleCenter)).Text = "Notifications";
toolbarImageFarLeft = (ImageView)toolbarLayout.FindViewById(Resource.Id.toolbar_imageFarLeft);
toolbarImageFarLeft.Visibility = ViewStates.Visible;
Drawable trash = Context.Resources.GetDrawable(Resource.Drawable.delete);
trash.SetColorFilter(Resources.GetColor(Resource.Color.tenBlue), PorterDuff.Mode.SrcAtop);
toolbarImageFarLeft.SetImageDrawable(trash);
toolbarImageFarLeft.Click += (sender, e) =>
{
Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(Context);
alert.SetTitle(Strings.clear_notificaitons);
alert.SetMessage(Strings.clear_notificaions_confirm);
alert.SetPositiveButton(Strings.yes, (senderAlert, args) =>
{
DeleteAllNotifications();
});
alert.SetNeutralButton(Strings.no, (senderAlert, args) => { });
alert.Show();
};
NotificationFragment = new NotificationFeedFragment();
NotificationFragment.Master = this;
NotificationFragment.Target = FeedTypeEnum.FeedType.NotificationFeed;
NotificationFragment.EmptyTableString = Strings.no_notifications;
NotificationFragment.NewPageContainerID = Resource.Id.search_container;
NotificationFragment.NoTableData += () =>
{
toolbarImageFarLeft.Visibility = ViewStates.Invisible;
};
NotificationFragment.HasTableData += () =>
{
toolbarImageFarLeft.Visibility = ViewStates.Visible;
};
FragmentManager.BeginTransaction().Add(Resource.Id.fragment_container, NotificationFragment).Commit();
return view;
}