答案 0 :(得分:0)
您需要创建自己的自定义进度条。
http://www.androiddevelopersolutions.com/2015/01/android-custom-horizontal-progress-bar.html
它并不完美,但你会有所了解。
或者试试这个插件SmoothProgressBar
答案 1 :(得分:0)
根据建议Pratik Mohanrao Gondil我使用this solution对VS XAMARIM进行了一些更改
Main.axml的部分
<Button
android:text="Button"
android:id="@+id/acceptPhoneButton"
android:minHeight="35dp"
android:textColor="#ffffff"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp" />
<RelativeLayout
android:id="@+id/progressLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<ImageView
android:id="@+id/progressImage"
android:src="@drawable/clip_source"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@drawable/progress_row_bg" />
</RelativeLayout>
clip_source.xml
<?xml version="1.0" encoding="utf-8" ?>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:clipOrientation="horizontal"
android:drawable="@drawable/progress_row"
android:gravity="left" />
MainActivity代码
using System.Timers;
using Android.Graphics.Drawables;
Timer _timer;
object _lock = new object();
bool phoneStatusFlag;
ImageView progressImage;
ClipDrawable mImageDrawable;
Button acceptPhoneButton;
private int mLevel = 0;
static int MAX_LEVEL = 10000;
static int LEVEL_DIFF = MAX_LEVEL/8;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Main);
acceptPhoneButton = FindViewById<Button>(Resource.Id.acceptPhoneButton);
progressImage = FindViewById<ImageView>(Resource.Id.progressImage);
phoneStatusFlag = false;
mImageDrawable = (ClipDrawable)progressImage.Drawable;
mImageDrawable.SetLevel(0);
acceptPhoneButton.Click += acceptPhone;
}
private void acceptPhone(object sender, EventArgs e)
{
acceptPhoneButton.Visibility = ViewStates.Invisible;
progressImage.Visibility = ViewStates.Visible;
_timer = new Timer();
_timer.Enabled = true;
_timer.Interval = 1000;
_timer.Elapsed += OnTimeEvent;
mImageDrawable.SetLevel(0);
}
private void OnTimeEvent(object sender, ElapsedEventArgs e)
{
RunOnUiThread(() =>
{
mLevel += LEVEL_DIFF;
mImageDrawable.SetLevel(mLevel);
CheckProgress(mImageDrawable.Level);
});
}
private void CheckProgress(int progress)
{
lock (_lock)
{
if (!phoneStatusFlag)
{
if (progress > MAX_LEVEL)
{
mLevel = 0;
mImageDrawable.SetLevel(mLevel);
}
}
else
{
mImageDrawable.SetLevel(0);
_timer.Close();
}
}
}