5
I’m having trouble leaving in the correct position of the flow with progress
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/checkout_hsv_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:id="@+id/progressBar"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/lineFluxos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
I dynamically add the images as the stream can be up to 3
int fluxosAutorizadosCount = 0;
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0,
ViewGroup.LayoutParams.WRAP_CONTENT);
lp.weight = 1;
for (int i = 0; i < fluxoList.size(); i++) {
ImageView image = new ImageView(getActivity());
if (fluxosAutorizadosCount < pedido.getFluxosAutorizados().size()) {
fluxosAutorizadosCount++;
image.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_circle));
} else {
image.setImageDrawable(getResources().getDrawable(R.drawable.ic_check_done));
}
image.setLayoutParams(lp);
lineFluxos.addView(image);
}
progressBar.setProgress((fluxosAutorizadosCount * 100) / fluxoList.size());
From what I can see, it seems like a mismatch between the value of the advance and where the checks are positioned. In this example the Progress marks 67% that is right for two checks, but as the check is in the middle of the block between 33% and 67% is misaligned. You can try to align this by placing it in the middle of the block by placing it in the prefix
67 - ((100 / 3 ) / 2)
, which is basicallyvalorProgress - ((100 / quantidadeChecks) / 2)
. Of course if you have changed the limits of the Progress needs to bevalorProgress - (((progMax - progMin) / quantidadeChecks) / 2)
– Isac