こんにちはすべてのプログラマー。私はアンドロイドアプリでカスタムプログレスバーを作成しようとしています。それはそれは、PBの並べ替えを行うことは可能ですアンドロイドで水平プログレスバーのスタイルをカスタマイズする
に見えるように持っており、それyesの場合、その後、どのように?
私はあらゆる種類の助けに感謝します。
こんにちはすべてのプログラマー。私はアンドロイドアプリでカスタムプログレスバーを作成しようとしています。それはそれは、PBの並べ替えを行うことは可能ですアンドロイドで水平プログレスバーのスタイルをカスタマイズする
に見えるように持っており、それyesの場合、その後、どのように?
私はあらゆる種類の助けに感謝します。
独自のカスタムプログレスバーを作成する必要があります。
http://www.androiddevelopersolutions.com/2015/01/android-custom-horizontal-progress-bar.html
それは完璧ではないですが、あなたのアイデアを得るでしょう。
それとも、このプラグインを試してみてくださいSmoothProgressBar
最初のリンクには説明しかありません。 Googleのコードのプロジェクトなし –
私は私の答えをedittedしている – ziLk
としては、私は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の一部のためにいくつかの変更をthis solutionを使用Pratik Mohanrao Gondilを示唆しました。 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に)それを見てください助けてくれるでしょう:)これが助けて欲しいと思っています:) –
@PratikMohanraoGondilはい、助けてくれてありがとうございます。 –