向所有程序员致以问候。我尝试在android应用程序中创建自定义进度条。它必须看起来像在android中自定义水平进度条风格
是否有可能做那种PB的,如果是的话,怎么样?
我将不胜感激所有类型的帮助。
向所有程序员致以问候。我尝试在android应用程序中创建自定义进度条。它必须看起来像在android中自定义水平进度条风格
是否有可能做那种PB的,如果是的话,怎么样?
我将不胜感激所有类型的帮助。
您将需要创建自己的自定义进度栏。
http://www.androiddevelopersolutions.com/2015/01/android-custom-horizontal-progress-bar.html
它并不完美,但你会得到一个想法。
或者试试这个插件SmoothProgressBar
只有第一个链接的描述。没有关于谷歌代码的项目 –
我编辑了我的答案 – ziLk
至于建议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();
}
}
}
请参阅此[链接](https://stackoverflow.com/questions/16893209/how-to-customize-a-progress-bar-in-android)它将有助于:)希望这有助于。:) –
To @PratikMohanraoGondil是的,这是帮助,谢谢。 –