示例#1
0
        public void Draw(Canvas canvas, bool hasPositionChanged)
        {
            if (ShouldDrawText())
            {
                float[] textPosition = GetBestTextPosition();

                if (!TextUtils.IsEmpty(mTitle))
                {
                    canvas.Save();
                    if (hasPositionChanged)
                    {
                        mDynamicTitleLayout = new DynamicLayout(mTitle, mPaintTitle, (int)textPosition[2], Layout.Alignment.AlignNormal, 1.0f, 1.0f, true);
                    }

                    canvas.Translate(textPosition[0], textPosition[1]);
                    mDynamicTitleLayout.Draw(canvas);
                    canvas.Restore();
                }

                if (!TextUtils.IsEmpty(mDetails))
                {
                    canvas.Save();
                    if (hasPositionChanged)
                    {
                        mDynamicDetailLayout = new DynamicLayout(mDetails, mPaintDetail, (int)textPosition[2], Layout.Alignment.AlignNormal, 1.2f, 1.0f, true);
                    }

                    canvas.Translate(textPosition[0], textPosition[1] + mDynamicTitleLayout.Height);
                    mDynamicDetailLayout.Draw(canvas);
                    canvas.Restore();
                }
            }
        }