解决方案 »

  1.   

    谢谢回复.
    不行的..第一个就是用的这种方法..完全无效果,父容器Parent都设置了.
      

  2.   

     你那个progressbar是什么背景呢?设置成一样的可以吗
      

  3.   

    谢谢回复
    不可以,必须label背景透明才行啊,progressbar进度条前进的时候颜色就变了.
      

  4.   

    如果要在进度条上写文字,可以扩展一个派生类自己画,不用label。看下这个例子: public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent(); var progressBar = new MyProgressBar()
    {
    Location = new Point(20, Bottom - 150),
    Size = new Size(Width - 60, 50),
    Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom
    };
    this.Controls.Add(progressBar); var timer = new Timer {Interval = 150};
    timer.Tick += (s, e) => progressBar.Value = progressBar.Value%100 + 1;
    timer.Start();
    } private void Form1_Load(object sender, EventArgs e)
    {
    }
    } public class MyProgressBar : ProgressBar
    {
    public MyProgressBar()
    {
    SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
    } protected override void OnPaint(PaintEventArgs e)
    {
    Rectangle rect = ClientRectangle;
    Graphics g = e.Graphics; ProgressBarRenderer.DrawHorizontalBar(g, rect);
    rect.Inflate(-3, -3);
    if (Value > 0)
    {
    var clip = new Rectangle(rect.X, rect.Y, (int) ((float) Value/Maximum*rect.Width), rect.Height);
    ProgressBarRenderer.DrawHorizontalChunks(g, clip);
    } string text = Value + "%";
    using (var font = new Font(FontFamily.GenericSerif, 20))
    {
    SizeF sz = g.MeasureString(text, font);
    var location = new PointF(rect.Width/2 - sz.Width/2, rect.Height/2 - sz.Height/2 + 2);
    g.DrawString(text, font, Brushes.Red, location);
    }
    }
    }
      

  5.   

    http://www.codeproject.com/Articles/33971/ProgressBar-with-Percentage
      

  6.   

    设置Label的width,先设置一个总长度,再按完成百分比改变width的长度
      

  7.   

    android:background="@null",这样就可以实现透明了,用transparent的话会有一层白的,不是完全透明的