当前位置: 首页>>代码示例>>C#>>正文


C# TextView.SetBackgroundResource方法代码示例

本文整理汇总了C#中Android.Widget.TextView.SetBackgroundResource方法的典型用法代码示例。如果您正苦于以下问题:C# TextView.SetBackgroundResource方法的具体用法?C# TextView.SetBackgroundResource怎么用?C# TextView.SetBackgroundResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Widget.TextView的用法示例。


在下文中一共展示了TextView.SetBackgroundResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetView

        // create a new ImageView for each item referenced by the Adapter
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            //Button tagButton;
            TextView tagButton;

            if (convertView == null)
            {  // if it's not recycled, initialize some attributes
                //tagButton = new Button(context);
                tagButton = new TextView(context);
                //tagButton.LayoutParameters = new GridView.LayoutParams(190, 190);
                tagButton.LayoutParameters = new GridView.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                tagButton.SetTextColor(Color.Rgb(34, 191, 185));
                //tagButton.SetPadding(5, 2, 5, 2);// ltrb
                tagButton.SetPadding(10, 4, 10, 4);// ltrb
                tagButton.SetBackgroundResource(Resource.Drawable.flame_style);

                //imageView.SetScaleType(ImageView.ScaleType.CenterCrop);
            }
            else
            {
                //tagButton = (Button)convertView;
                tagButton = (TextView)convertView;
            }

            // Bitmap bmp = MediaStore.Images.Thumbnails.GetThumbnail(cr, items[position].ImageId, ThumbnailKind.MicroKind, null);
            //imageView.SetImageBitmap(bmp);
            tagButton.Text = items[position].TagStr;
            return tagButton;
        }
开发者ID:yasu0796,项目名称:XamarinCloudVisionApp,代码行数:30,代码来源:TagAdapter.cs

示例2: NoteRepresentation

        /// <summary>
        /// Constructs a new representation as a visual ball with a number of string in its center.
        /// </summary>
        /// <param name="currentActivity">The activity on which the ball should be drawn.</param>
        /// <param name="note">The note that should be played correspondingly when visually arriving to the guitar's neck.</param>
        public NoteRepresentation(Activity currentActivity, Note note)
        {
            //Basic values.
            _currentActivity = currentActivity;
            _note = note;

            //The color of the ball.
            BallColor ballColor = (BallColor)note.Position.String; //note.Position.Fret;
            //Which string the number on the ball should represent.
            //GuitarString stringNum = note.Position.String;

            _noteCircle = new TextView(_currentActivity);

            //Select the ball's color.
            switch (ballColor)
            {
                case BallColor.Red:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_red);
                    break;
                case BallColor.Purple:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_purple);
                    break;
                case BallColor.Blue:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_blue);
                    break;
                case BallColor.Green:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_green);
                    break;
                case BallColor.Orange:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_orange);
                    break;
                case BallColor.Aqua:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_aqua);
                    break;
                case BallColor.Yellow:
                    _noteCircle.SetBackgroundResource(Resource.Drawable.ball_yellow);
                    break;
            }

            //Set dimensions.
            _noteCircle.Layout(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
            //Center text.
            _noteCircle.Gravity = GravityFlags.Center;
            //Set text.
            //_noteCircle.SetText(((int)stringNum).ToString(), TextView.BufferType.Normal);
            //Refresh view.
            _noteCircle.RequestLayout();

            //Add the newly created note circle to the current activity.
            _currentActivity.AddContentView(_noteCircle, new ViewGroup.LayoutParams(BUTTON_WIDTH, BUTTON_HEIGHT));
        }
开发者ID:sagisprojects,项目名称:Virtual-Guitar-Teacher,代码行数:56,代码来源:NoteRepresentation.cs

示例3: SetTimeRemaining

		public static void SetTimeRemaining(Post post, TextView timeRemainingTextView, ImageView clockImageView)
		{
			if (post.IsExpired())
			{
				timeRemainingTextView.Text = StringUtils.GetTopTime(post);
				timeRemainingTextView.SetTextColor(Color.White);
				timeRemainingTextView.SetBackgroundResource(Resource.Drawable.RoundedCorners5Black);
				clockImageView.Visibility = ViewStates.Invisible;
			}
			else
			{
				timeRemainingTextView.Text = StringUtils.GetPrettyDateAbs(post.expiration);
				timeRemainingTextView.SetTextColor(ViewUtils.GetTimeRemainingColor(post.expiration));
				//timeRemainingTextView.SetBackgroundColor(Android.Graphics.Color.Transparent);
				clockImageView.Visibility = ViewStates.Visible;
			}
		}
开发者ID:natevarghese,项目名称:XamarinTen,代码行数:17,代码来源:ViewUtils.cs

示例4: GetView

        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            TextView button = new TextView(context);
            button.SetText(chapters[position], TextView.BufferType.Normal);
            button.TextSize = 32;
            button.SetTypeface(ThisApp.Font(context, "ionbold"), Android.Graphics.TypefaceStyle.Normal);
            button.SetHeight(84);
            button.SetBackgroundResource(Resource.Drawable.metro_button_style);
            button.Gravity = GravityFlags.Center;
            //button.SetPadding(0, 0, 0, 0);
            //button.SetTextColor(Resources.System.GetColorStateList(Resource.Color.metro_button_text_style));
            //button.SetTextColor(Resources.System.GetColor(Resource.Color.metro_button_text_style));
            button.Id = position;

            button.Click += button_Click;

            return button;
        }
开发者ID:PablusVinii,项目名称:SuperNWTBible,代码行数:18,代码来源:ChaptersActivity.cs

示例5: createFingerTraceView

        /**
         * Creates a new view that will be used to display the specified pointer id on the touchpad
         * view.
         *
         * @param pointerId the id of the pointer that this finger trace view will represent; used to
         *     determine its color and text
         * @return the {@code TextView} that was created
         */
        private TextView createFingerTraceView(int pointerId)
        {
            var fingerTraceView = new TextView(Context); 
            fingerTraceView.SetBackgroundResource(FINGER_RES_IDS[pointerId]);
            fingerTraceView.Text = pointerId.ToString();
            fingerTraceView.Gravity = GravityFlags.Center;
            fingerTraceView.SetTextAppearance(Context, Android.Resource.Style.TextAppearanceDeviceDefaultSmall);
            fingerTraceView.Alpha = 0;

            var lp = new RelativeLayout.LayoutParams(FINGER_TRACE_SIZE, FINGER_TRACE_SIZE);
            lp.AddRule(LayoutRules.AlignParentTop);
            lp.AddRule(LayoutRules.AlignParentLeft);

            // The right and bottom margin here are required so that the view doesn't get "squished"
            // as it touches the right or bottom side of the touchpad view.
            lp.RightMargin = -2 * FINGER_TRACE_SIZE;
            lp.BottomMargin = -2 * FINGER_TRACE_SIZE;
            fingerTraceView.LayoutParameters = lp;

            return fingerTraceView;
        }
开发者ID:42Spikes,项目名称:F2S,代码行数:29,代码来源:TouchpadView.cs

示例6: createUI

        private void createUI(MessageDB message, UserDB contact)
        {
            #if DEBUG
            System.Diagnostics.Debug.WriteLine ("AccoundID (MC) = {0}", AndroidData.CurrentUser.AccountID.ToString ());
            #endif
            int m = 0;
            string messager = "";
            if (message != null && contact != null) {
                RunOnUiThread (delegate {
                    ImageView random = null;
                    LinearLayout layout = new LinearLayout (context);
                    layout.Orientation = Android.Widget.Orientation.Horizontal;
                    layout.SetGravity (GravityFlags.CenterVertical);
                    layout.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (10f, context));

                    ImageView profilepic = new ImageView (context);
                    profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (60f, context), (int)ImageHelper.convertDpToPixel (100f, context));
                    profilepic.Tag = new Java.Lang.String ("profilepic_" + m.ToString ());

                    if (contact == null)
                        profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage));
                    else {
                        if (contact.Picture.Length > 0) {
                            //profilepic.SetImageDrawable(Android.Graphics.Drawables.Drawable.CreateFromStream(new MemoryStream(eachContact.ContactUser.Picture), "Profile"));
                            loadProfilePicture (contact.AccountID);
                        } else {
                            profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage));
                        }

                        //layout.AddView(profilepic);

                        LinearLayout layout2 = new LinearLayout (context);
                        layout2.Orientation = Orientation.Vertical;
                        layout2.SetGravity (GravityFlags.Center);

                        TextView name = new TextView (context);
                        name.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (260f, context), (int)ImageHelper.convertDpToPixel (40f, context));
                        name.Gravity = GravityFlags.Center;
                        name.SetTextColor (Color.White);
                        name.TextSize = 16f;
                        name.Text = contact.FirstName + " " + contact.LastName;

                        layout2.AddView (name);

                        TextView text = new TextView (context);
                        text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (240f, context), (int)ImageHelper.convertDpToPixel (60f, context));
                        text.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0);
                        text.Gravity = GravityFlags.CenterVertical;
                        if (name.Text == isMe)
                            text.SetBackgroundResource (Resource.Drawable.bubblesolidright);
                        else
                            text.SetBackgroundResource (Resource.Drawable.bubblesolidleft);

                        text.TextSize = 16f;

                        for (int e = 0; e < message.MessageStepDBList.Count; ++e) {
                            if (!string.IsNullOrEmpty (message.MessageStepDBList [e].MessageText)) {
                                messager = message.MessageStepDBList [e].MessageText;
                                break;
                            }
                        }

                        if (string.IsNullOrEmpty (messager))
                            messager = "No text message found";

                        int nolines = messager.Length / 27;
                        text.SetHeight ((nolines + 1) * 20);

                        text.SetTextColor (Android.Graphics.Color.Black);
                        text.Text = messager;
                        layout2.Clickable = true;
                        layout2.AddView (text);
                        if (message.MessageStepDBList.Count > 1) {
                            LinearLayout layout3 = new LinearLayout (context);
                            layout3.Orientation = Orientation.Horizontal;
                            if (name.Text == isMe)
                                layout3.SetGravity (GravityFlags.Right);
                            else
                                layout3.SetGravity (GravityFlags.Left);
                            layout3.SetBackgroundResource (Resource.Drawable.attachmentspreviewbkgr);
                            layout3.SetVerticalGravity (GravityFlags.CenterVertical);
                            layout3.SetMinimumHeight (30);
                            layout3.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0);

                            if (name.Text != isMe) {
                                random = new ImageView (context);
                                random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context));
                                random.SetBackgroundResource (Resource.Drawable.playblack);
                                //random.Click += delegate { PlayMessage(message); };
                                layout3.AddView (random);
                            }

                            for (int i = 1; i < message.MessageStepDBList.Count; ++i) {
                                switch (message.MessageStepDBList [i].StepType) {
                                case LOLMessageDelivery.MessageStep.StepTypes.Animation:
                                    random = new ImageView (context);
                                    random.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (30f, context), (int)ImageHelper.convertDpToPixel (30f, context));
                                    random.SetBackgroundResource (Resource.Drawable.drawicon);
                                    layout3.AddView (random);
                                    break;
//.........这里部分代码省略.........
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:101,代码来源:ConversationActivity.cs

示例7: OnCreateView


//.........这里部分代码省略.........
                        } else {
                            boardcardlist.Add (new TeamLeaderBoardCard (eventcard.eventinfo.groupLeaderBoardList[i], 2));
                        }
                    }
                    leaderboardadapter = new LeaderBoardAdapter (nn_activity, boardcardlist, selfcard, true);
                }else {
                    leaderboardadapter = new LeaderBoardAdapter (nn_activity, new List<TeamLeaderBoardCard> (), new LeaderBoardSelfCard("0","0"),true);
                }

            //GET CONTAINER
            goalscontainer=(RelativeLayout)view.FindViewById (Resource.Id.raffledetail_goalsbodycontainer_relativelayout);
            goalscontainer.Visibility = ViewStates.Invisible;
            //goalscontainer.SetBackgroundResource(Resource.Drawable.bg_relativelayout_grayround);

            RelativeLayout slideritemcontainer = new RelativeLayout (nn_activity);
            slideritemcontainer.LayoutParameters=new RelativeLayout.LayoutParams ( RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent);
            //slideritemcontainer.SetPadding (TapUtil.dptodx(30),TapUtil.dptodx(10),TapUtil.dptodx(30),TapUtil.dptodx(10));

            try{
                DateTime eventEndTime=DateTime.ParseExact (eventcard.eventinfo.event_end_time.Substring (0, 19),
                    "yyyy-MM-ddTHH:mm:ss", null);
                hours=(eventEndTime-DateTime.Now).TotalHours;
            }
            catch{
                hours = 0;
            }

            daybartextview = new TextView (nn_activity);
            int leftday = (int)hours / 24;
            int lefthours = (int)hours % 24;
            daybartextview.Text = string.Format (" "+leftday+" Days,"+" "+lefthours+" Hours");
            daybartextview.Gravity = GravityFlags.Center;
            daybartextview.Typeface = Typeface.DefaultBold;
            daybartextview.SetBackgroundResource(Resource.Color.iosblue);
            daybartextview.TextSize = TapUtil.dptodx (8);
            daybartextview.SetTextColor (Color.White);
            daybartextview.Id = TapUtil.generateViewId ();
            RelativeLayout.LayoutParams daybartextviewparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent);
            daybartextviewparam.TopMargin=TapUtil.dptodx (10);
            daybartextviewparam.LeftMargin=TapUtil.dptodx (5);
            daybartextviewparam.RightMargin=TapUtil.dptodx (5);
            daybartextview.LayoutParameters = daybartextviewparam;
            slideritemcontainer.AddView (daybartextview);

            circlepanelrealtivelayout = new RelativeLayout (nn_activity);
            //circlepanelrealtivelayout.SetBackgroundResource (Resource.Drawable.bg_relativelayout_grayround);
            circlepanelrealtivelayout.Id = TapUtil.generateViewId ();
            RelativeLayout.LayoutParams circlepanelparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent);
            //circlepanelparam.TopMargin=TapUtil.dptodx(20);
            circlepanelparam.AddRule (LayoutRules.Below, daybartextview.Id);
            circlepanelrealtivelayout.LayoutParameters= circlepanelparam;
            circlepanelrealtivelayout.SetPadding (TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5), TapUtil.dptodx (5));

            personalprogresslabel = new TextView (nn_activity);
            personalprogresslabel.Text=GoalScreenData.personalProgressLabelText;

            RelativeLayout.LayoutParams personalprogresslabelparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent);
            personalprogresslabel.LayoutParameters = personalprogresslabelparam;
            personalprogresslabel.Gravity = GravityFlags.Center;
            personalprogresslabel.Typeface = Typeface.DefaultBold;
            personalprogresslabel.Id = TapUtil.generateViewId ();

            goalslinearlayout = new LinearLayout (nn_activity);
            RelativeLayout.LayoutParams goalslayoutparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent);
            goalslayoutparam.AddRule (LayoutRules.Below, personalprogresslabel.Id);
            goalslayoutparam.TopMargin = TapUtil.dptodx (10);
开发者ID:MADMUC,项目名称:TAP5050,代码行数:67,代码来源:RaffleDetailFragment.cs

示例8: CreateMessagesUI

        private void CreateMessagesUI()
        {
            List<UserDB> participants = new List<UserDB> ();
            bool moreThanOne = false, isCurrentMe = false;

            if (MessageConversations.clearView) {
                listWrapper.RemoveAllViews ();
                MessageConversations.clearView = false;
            }

            if (Contacts.SelectContactsUtil.selectedContacts.Count != 0)
                Contacts.SelectContactsUtil.selectedContacts.Clear ();

            if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList.Count > 1) {
                moreThanOne = true;
                for (int m = 0; m < MessageConversations.currentConversationMessages[0].MessageRecipientDBList.Count; ++m) {
                    if (MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid != AndroidData.CurrentUser.AccountID.ToString ()) {
                        UserDB userDetails = dbm.GetUserWithAccountID (MessageConversations.currentConversationMessages [0].MessageRecipientDBList [m].AccountGuid);
                        participants.Add (userDetails);
                        ContactDB contact = new ContactDB ();
                        contact.ContactUser = new LOLAccountManagement.User ();
                        contact.ContactUser.AccountID = userDetails.AccountID;
                        Contacts.SelectContactsUtil.selectedContacts.Add (contact);
                    } else {
                        UserDB userDetails = UserDB.ConvertFromUser (AndroidData.CurrentUser);
                        participants.Add (userDetails);
                    }
                }
            } else {
                UserDB userDetails = dbm.GetUserWithAccountID (MessageConversations.currentConversationMessages [0].MessageRecipientDBList [0].AccountGuid);
                ContactDB contact = new ContactDB ();
                contact.ContactUser = new LOLAccountManagement.User ();
                contact.ContactUser.AccountID = userDetails.AccountID;
                Contacts.SelectContactsUtil.selectedContacts.Add (contact);
            }

            if (moreThanOne) {
                string toReturn = "";
                List<UserDB> sortedList = new List<UserDB> ();
                sortedList = participants.OrderBy (s => s.LastName).OrderBy (s => s.FirstName).ToList ();
                foreach (UserDB eachItem in sortedList)
                    toReturn += string.Format ("{0} {1}, ", eachItem.FirstName, eachItem.LastName);
                int last = toReturn.LastIndexOf (", ");
                toReturn = toReturn.Remove (last);

                using (LinearLayout btnlayout = new LinearLayout (context)) {
                    btnlayout.Orientation = Android.Widget.Orientation.Vertical;
                    btnlayout.SetGravity (GravityFlags.Center);
                    btnlayout.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
                    btnlayout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context));

                    using (TextView name = new TextView(context)) {
                        name.Text = toReturn;
                        name.SetTextSize (Android.Util.ComplexUnitType.Dip, 18f);
                        name.SetTextColor (Color.Black);
                        RunOnUiThread (() => btnlayout.AddView (name));
                    }

                    using (Button showAll = new Button (context)) {
                        showAll.Gravity = GravityFlags.CenterVertical;
                        showAll.Text = Application.Context.Resources.GetString (Resource.String.messageShowAllInConversation);
                        showAll.Click += (object sender, EventArgs e) => {
                            showParticipants (sender, e, participants); };
                        showAll.SetWidth ((int)ImageHelper.convertDpToPixel (180f, context));
                        showAll.SetHeight ((int)ImageHelper.convertDpToPixel (30f, context));
                        showAll.SetBackgroundResource (Resource.Drawable.button);
                        RunOnUiThread (() => btnlayout.AddView (showAll));
                    }
                    RunOnUiThread (() => listWrapper.AddView (btnlayout));
                }

            }
            foreach (MessageDB message in MessageConversations.currentConversationMessages) {
                isCurrentMe = message.FromAccountID != AndroidData.CurrentUser.AccountID ? false : true;
                LinearLayout shell = new LinearLayout (context);
                shell.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, (int)ImageHelper.convertDpToPixel (imageSize [0] + 50f, context));
                shell.Orientation = Orientation.Horizontal;
                shell.SetPadding (0, 0, 0, (int)ImageHelper.convertDpToPixel (5f, context));

                UserDB whoAmI = new UserDB ();
                whoAmI = message.FromAccountID != AndroidData.CurrentUser.AccountID ? dbm.GetUserWithAccountID (message.FromAccountGuid) : UserDB.ConvertFromUser (AndroidData.CurrentUser);

                LinearLayout imageViewLayout = new LinearLayout (context);
                imageViewLayout.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);
                imageViewLayout.SetGravity (GravityFlags.CenterVertical);
                ImageView userImage = new ImageView (context);
                if (Contacts.ContactsUtil.contactFilenames.Contains (message.FromAccountGuid)) {
                    using (Bitmap bm = BitmapFactory.DecodeFile (System.IO.Path.Combine (wowZapp.LaffOutOut.Singleton.ImageDirectory, message.FromAccountGuid))) {
                        using (MemoryStream ms = new MemoryStream ()) {
                            bm.Compress (Bitmap.CompressFormat.Jpeg, 80, ms);
                            byte[] image = ms.ToArray ();
                            using (Bitmap myBitmap = ImageHelper.CreateUserProfileImageForDisplay(image, (int)imageSize[0], (int)imageSize[1], this.Resources)) {
                                RunOnUiThread (delegate {
                                    userImage.SetImageBitmap (myBitmap);
                                });
                            }
                        }
                    }
                } else {
                    userImage.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (imageSize [0], context), (int)ImageHelper.convertDpToPixel (imageSize [1], context));
//.........这里部分代码省略.........
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:101,代码来源:MessageListUI-original.cs

示例9: CreateDefaultTabView

		private TextView CreateDefaultTabView(Android.Content.Context context)
		{
			TextView textView = new TextView(context);
			textView.LayoutParameters = new LinearLayout.LayoutParams (0, ViewGroup.LayoutParams.WrapContent, 1f);
			textView.Gravity = GravityFlags.Center;
			textView.SetTextSize(ComplexUnitType.Sp, TAB_VIEW_TEXT_SIZE_SP);
			textView.Typeface = Android.Graphics.Typeface.DefaultBold;

			if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Honeycomb)
			{
				TypedValue outValue = new TypedValue();
				Context.Theme.ResolveAttribute(Android.Resource.Attribute.SelectableItemBackground, outValue, false);
				textView.SetBackgroundResource(outValue.ResourceId);
			}

			if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.IceCreamSandwich)
			{
				textView.SetAllCaps(true);
			}

			int padding = (int)(TAB_VIEW_PADDING_DIPS * Resources.DisplayMetrics.Density);
			textView.SetPadding(padding, padding, padding, padding);

			return textView;
		}
开发者ID:kktanpiya,项目名称:kimuraHazuki048,代码行数:25,代码来源:SlidingTabScrollView.cs

示例10: contactUserInterface

        private LinearLayout contactUserInterface(MessageDB message, UserDB contact, bool direction)
        {
            LinearLayout layout = new LinearLayout (context);
            layout.Orientation = Android.Widget.Orientation.Horizontal;
            layout.SetGravity (GravityFlags.CenterVertical);
            string messager = "";
            layout.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context), (int)ImageHelper.convertDpToPixel (10f, context));
            ImageView profilepic = new ImageView (context);
            if (!direction) {
                profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context));

                if (contact == null)
                    profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage));
                else {
                    profilepic.Tag = new Java.Lang.String ("profilepic_" + contact.AccountID);
                    profilepic.SetImageResource (Resource.Drawable.defaultuserimage);
                    layout.AddView (profilepic);
                    if (contact.Picture.Length == 0 && contact.HasProfileImage)
                        getGuid.Add (contact.AccountID);
                    else {
                        if (contact.Picture.Length > 0)
                            LoadUserImage (contact, profilepic);
                        else
                            profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage));
                    }

                    LinearLayout layout2 = new LinearLayout (context);
                    layout2.Orientation = Orientation.Vertical;
                    layout2.SetGravity (GravityFlags.Center);

                    if (message.MessageStepDBList.Count == 1 && message.MessageStepDBList [0].StepType == MessageStep.StepTypes.Text) {
                        TextView text = new TextView (context);
                        text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context));
                        text.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0);
                        text.Gravity = GravityFlags.CenterVertical;
                        text.SetBackgroundResource (Resource.Drawable.bubblesolidright);
                        text.TextSize = 16f;

                        for (int e = 0; e < message.MessageStepDBList.Count; ++e) {
                            if (!string.IsNullOrEmpty (message.MessageStepDBList [e].MessageText)) {
                                messager = message.MessageStepDBList [e].MessageText;
                                break;
                            }
                        }

                        if (string.IsNullOrEmpty (messager))
                            messager = "No text message found";

                        int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context));
                        text.SetHeight (nolines);

                        text.SetTextColor (Android.Graphics.Color.Black);
                        text.Text = messager;
                        layout2.Clickable = true;
                        layout2.AddView (text);
                    }
                    layout.AddView (layout2);
                }
            } else {
                LinearLayout layout2 = new LinearLayout (context);
                layout2.Orientation = Orientation.Vertical;
                layout2.SetGravity (GravityFlags.Center);

                if (message.MessageStepDBList.Count == 1 && message.MessageStepDBList [0].StepType == MessageStep.StepTypes.Text) {
                    TextView text = new TextView (context);
                    text.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (220f, context), (int)ImageHelper.convertDpToPixel (60f, context));
                    text.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0);
                    text.Gravity = GravityFlags.CenterVertical;
                    text.SetBackgroundResource (Resource.Drawable.bubblesolidleft);
                    text.TextSize = 16f;

                    for (int e = 0; e < message.MessageStepDBList.Count; ++e) {
                        if (!string.IsNullOrEmpty (message.MessageStepDBList [e].MessageText)) {
                            messager = message.MessageStepDBList [e].MessageText;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty (messager))
                        messager = "No text message found";

                    int nolines = (int)(ImageHelper.convertDpToPixel ((messager.Length / 27f) * 12f, context));
                    text.SetHeight (nolines);

                    text.SetTextColor (Android.Graphics.Color.Black);
                    text.Text = messager;
                    layout2.Clickable = true;
                    layout2.AddView (text);
                }
                profilepic.LayoutParameters = new ViewGroup.LayoutParams ((int)ImageHelper.convertDpToPixel (55f, context), (int)ImageHelper.convertDpToPixel (100f, context));
                layout.AddView (layout2);
                if (contact == null)
                    profilepic.SetImageDrawable (Application.Context.Resources.GetDrawable (Resource.Drawable.defaultuserimage));
                else {
                    profilepic.Tag = new Java.Lang.String ("profilepic_" + contact.AccountID);
                    profilepic.SetImageResource (Resource.Drawable.defaultuserimage);
                    layout.AddView (profilepic);
                    if (contact.Picture.Length == 0 && contact.HasProfileImage)
                        getGuid.Add (contact.AccountID);
                    else {
//.........这里部分代码省略.........
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:101,代码来源:MessageReceivedActivityUI.cs

示例11: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Details);
            // Create your application here
            try
            {
                _mMapView = FindViewById<MapView>(Resource.Id.bmapView);
                var txtHotelName = FindViewById<TextView>(Resource.Id.txtHotelName);
                var txtHotelCoordinate = FindViewById<TextView>(Resource.Id.txtHotelCoordinate);
                _btnReserve = FindViewById<Button>(Resource.Id.btnReserve);


                #region 数据初始化

                //var hotelEntity =(HotelEntity) Intent.GetSerializableExtra("HOTELENTITY");
                var name = Intent.GetStringExtra("Name");
                var latitude = Intent.GetDoubleExtra("Latitude", 0.00);
                var longitude = Intent.GetDoubleExtra("Longitude", 0.00);
                _hotelEntity = new HotelEntity() { Name = name, Latitude = latitude, Longitude = longitude };

                txtHotelName.Text = _hotelEntity.Name;
                txtHotelCoordinate.Text = string.Format("({0}, {1})", _hotelEntity.Longitude.ToString("0.0000"), _hotelEntity.Latitude.ToString("0.0000"));

                #endregion 数据初始化

                _mBaiduMap = _mMapView.Map;
                #region 标记酒店位置

                InitOverlay();

                #endregion 标记酒店位置

                #region 添加事件
                // _mBaiduMap.SetOnMarkerClickListener(new OnMarkerClickListener(this));
                _mBaiduMap.MarkerClick += (sender, args) =>
                {
                    var marker = args.P0;
                    try
                    {
                        HotelEntity entity = marker.ExtraInfo.GetSerializable("info") as HotelEntity;

                        TextView location = new TextView(ApplicationContext);
                        location.SetBackgroundResource(Resource.Drawable.infowindow_bg);
                        location.SetPadding(30, 20, 30, 50);
                        if (entity != null) location.Text = entity.Name;

                        var latlng = marker.Position;
                        var point = _mBaiduMap.Projection.ToScreenLocation(latlng);
                        Log.Info(Tag, "--!" + point.X + " , " + point.Y);
                        point.Y -= 47;
                        var pointInfo = _mBaiduMap.Projection.FromScreenLocation(point);
                        var window = new InfoWindow(location, pointInfo, 0);
                        _mBaiduMap.ShowInfoWindow(window);
                    }
                    catch (Exception ex)
                    {

                        Log.Error(Tag, "MarkerClick Excetipn :" + ex.Message);
                    }
                };
                //_mBaiduMap.SetOnMapClickListener(new OnMapClickListener(this));
                _mBaiduMap.MapClick += (sender, args) =>
                {
                    _mBaiduMap.HideInfoWindow();
                };
                _btnReserve.Click += (sender, args) =>
                {
                    StartActivity(new Intent(this, typeof(PayLayout)));
                };

                #endregion


            }
            catch (Exception ex)
            {
                Log.Error(Tag, ex.StackTrace);
            }
        }
开发者ID:MicahelWang,项目名称:XamarinSamples,代码行数:80,代码来源:DetailsActivity.cs

示例12: NodeClick

        /**
         * 节点浏览示例
         * @param v
         */
        public void NodeClick(View v)
        {
            viewCache = LayoutInflater.Inflate(Resource.Layout.custom_text_view, null);
            popupText = viewCache.FindViewById<TextView>(Resource.Id.textcache);
            if (searchType == 0 || searchType == 2)
            {
                //驾车、步行使用的数据结构相同,因此类型为驾车或步行,节点浏览方法相同
                if (nodeIndex < -1 || route == null || nodeIndex >= route.NumSteps)
                    return;

                //上一个节点
                if (mBtnPre.Equals(v) && nodeIndex > 0)
                {
                    //索引减
                    nodeIndex--;
                    //移动到指定索引的坐标
                    mMapView.Controller.AnimateTo(route.GetStep(nodeIndex).Point);
                    //弹出泡泡
                    popupText.SetBackgroundResource(Resource.Drawable.popup);
                    popupText.Text = route.GetStep(nodeIndex).Content;
                    pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText),
                            route.GetStep(nodeIndex).Point,
                            5);
                }
                //下一个节点
                if (mBtnNext.Equals(v) && nodeIndex < (route.NumSteps - 1))
                {
                    //索引加
                    nodeIndex++;
                    //移动到指定索引的坐标
                    mMapView.Controller.AnimateTo(route.GetStep(nodeIndex).Point);
                    //弹出泡泡
                    popupText.SetBackgroundResource(Resource.Drawable.popup);
                    popupText.Text = route.GetStep(nodeIndex).Content;
                    pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText),
                            route.GetStep(nodeIndex).Point,
                            5);
                }
            }
            if (searchType == 1)
            {
                //公交换乘使用的数据结构与其他不同,因此单独处理节点浏览
                if (nodeIndex < -1 || transitOverlay == null || nodeIndex >= transitOverlay.AllItem.Count)
                    return;

                //上一个节点
                if (mBtnPre.Equals(v) && nodeIndex > 1)
                {
                    //索引减
                    nodeIndex--;
                    //移动到指定索引的坐标
                    mMapView.Controller.AnimateTo(transitOverlay.GetItem(nodeIndex).Point);
                    //弹出泡泡
                    popupText.SetBackgroundResource(Resource.Drawable.popup);
                    popupText.Text = transitOverlay.GetItem(nodeIndex).Title;
                    pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText),
                            transitOverlay.GetItem(nodeIndex).Point,
                            5);
                }
                //下一个节点
                if (mBtnNext.Equals(v) && nodeIndex < (transitOverlay.AllItem.Count - 2))
                {
                    //索引加
                    nodeIndex++;
                    //移动到指定索引的坐标
                    mMapView.Controller.AnimateTo(transitOverlay.GetItem(nodeIndex).Point);
                    //弹出泡泡
                    popupText.SetBackgroundResource(Resource.Drawable.popup);
                    popupText.Text = transitOverlay.GetItem(nodeIndex).Title;
                    pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText),
                            transitOverlay.GetItem(nodeIndex).Point,
                            5);
                }
            }

        }
开发者ID:hnhhzy,项目名称:BaiduMap_SDK_DEMO_for_Xamarin.Android,代码行数:80,代码来源:RoutePlanDemo.cs

示例13: CreateDefaultTabView

        private TextView CreateDefaultTabView(Context context)
        {
            var textView = new TextView(context);
            textView.Gravity = GravityFlags.Center;
            textView.SetTextSize(ComplexUnitType.Sp, TabViewTextSizeSp);
            textView.Typeface = Typeface.DefaultBold;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                var outValue = new TypedValue();
                Context.Theme.ResolveAttribute(Resource.Attribute.SelectableItemBackground, outValue, false);
                textView.SetBackgroundResource(outValue.ResourceId);
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich)
            {
                textView.SetAllCaps(true);
            }

            var padding = (int) (TabViewPaddingDips*Resources.DisplayMetrics.Density);
            textView.SetPadding(padding, padding, padding, padding);

            return textView;
        }
开发者ID:BenjaminSheffield,项目名称:AndroidFragranceApp,代码行数:24,代码来源:SlidingTabScrollView.cs

示例14: NodeClick

        /**
         * 节点浏览示例
         * @param v
         */
        public void NodeClick(View v)
        {

            if (nodeIndex < -1 || route == null || nodeIndex >= route.NumSteps)
                return;
            viewCache = LayoutInflater.Inflate(Resource.Layout.custom_text_view, null);
            popupText = viewCache.FindViewById<TextView>(Resource.Id.textcache);
            //上一个节点
            if (mBtnPre.Equals(v) && nodeIndex > 0)
            {
                //索引减
                nodeIndex--;
                //移动到指定索引的坐标
                mMapView.Controller.AnimateTo(route.GetStep(nodeIndex).Point);
                //弹出泡泡
                popupText.Text = route.GetStep(nodeIndex).Content;
                popupText.SetBackgroundResource(Resource.Drawable.popup);
                pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText),
                        route.GetStep(nodeIndex).Point,
                        5);
            }
            //下一个节点
            if (mBtnNext.Equals(v) && nodeIndex < (route.NumSteps - 1))
            {
                //索引加
                nodeIndex++;
                //移动到指定索引的坐标
                mMapView.Controller.AnimateTo(route.GetStep(nodeIndex).Point);
                //弹出泡泡
                popupText.Text = route.GetStep(nodeIndex).Content;
                popupText.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.popup));
                pop.ShowPopup(BMapUtil.GetBitmapFromView(popupText),
                        route.GetStep(nodeIndex).Point,
                        5);
            }
        }
开发者ID:hnhhzy,项目名称:BaiduMap_SDK_DEMO_for_Xamarin.Android,代码行数:40,代码来源:BusLineSearchDemo.cs

示例15: SetTimeRemaining

		private void SetTimeRemaining(NotificationFeedFragment master, int containerId, Notification notification, TextView timeRemainingTextView, ImageView clockImageView)
		{
			if (
				notification.type == Strings.notification_type_post_expired ||
				notification.type == Strings.notification_type_following ||
				notification.type == Strings.notification_type_follow ||
				notification.type == Strings.notification_type_friend_request)
			{
				clockImageView.Visibility = ViewStates.Invisible;
				timeRemainingTextView.Visibility = ViewStates.Invisible;
			}
			else {
				clockImageView.Visibility = ViewStates.Visible;
				timeRemainingTextView.Visibility = ViewStates.Visible;

				if (notification.post != null)
				{
					if (notification.post.IsExpired())
					{
						string timeRemaining = StringUtils.GetTopTime(notification.post);
						timeRemainingTextView.Text = timeRemaining;
						timeRemainingTextView.SetTextColor(Color.White);
						timeRemainingTextView.SetBackgroundResource(Resource.Drawable.RoundedCorners5Black);
						clockImageView.Visibility = ViewStates.Invisible;
					}
					else {
						string timeRemaining = StringUtils.GetPrettyDateAbs(notification.post.expiration);
						timeRemainingTextView.Text = timeRemaining;

						Color timeRemainingColor = ViewUtils.GetTimeRemainingColor(notification.post.expiration);
						timeRemainingTextView.SetTextColor(timeRemainingColor);
						timeRemainingTextView.SetBackgroundColor(Color.Transparent);
						clockImageView.Visibility = ViewStates.Visible;
					}
				}
				if (!clockImageView.HasOnClickListeners)
				{
					clockImageView.Click += (sender, e) =>
					{
						TenServiceHelper.GoToListOf(master.FragmentManager, containerId, notification.post.idPost, FeedTypeEnum.FeedType.LikersListOfFeed);
					};
				}
				if (!timeRemainingTextView.HasOnClickListeners)
				{
					timeRemainingTextView.Click += (sender, e) =>
					{
						TenServiceHelper.GoToListOf(master.FragmentManager, containerId, notification.post.idPost, FeedTypeEnum.FeedType.LikersListOfFeed);
					};
				}
			}
		}
开发者ID:natevarghese,项目名称:XamarinTen,代码行数:51,代码来源:NotificationView.cs


注:本文中的Android.Widget.TextView.SetBackgroundResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。