Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid, How to disable repeate of background image in customized progressbar?
    primarykey
    data
    text
    <p>I have customised progressbar. HorizontalSlider class which inherits from ProgressBar is:</p> <pre><code>import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.ProgressBar; public class HorizontalSlider extends ProgressBar { private OnProgressChangeListener listener; private static final int padding = 2; private static final int getMin = 11; public interface OnProgressChangeListener { void onProgressChanged(View v, int progress); } public HorizontalSlider(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, android.R.attr.progressBarStyleHorizontal); } public HorizontalSlider(Context context, AttributeSet attrs) { super(context, attrs); } public HorizontalSlider(Context context) { super(context); } public void setOnProgressChangeListener(OnProgressChangeListener l) { listener = l; } @Override public boolean onTouchEvent(MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) { float x_mouse = event.getX() - padding; float width = getWidth() - 2 * padding; int progress = Math.round((float) getMax() * (x_mouse / width)); if (progress &lt; getMin) progress = getMin; if (progress &gt; getMax()) progress = getMax(); this.setProgress(progress); if (listener != null) listener.onProgressChanged(this, progress); } return true; } } </code></pre> <p>UI in xml format is:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="10dip" android:paddingRight="10dip" android:paddingTop="100dip" android:gravity="center_horizontal" &gt; &lt;com.astro.mania.classes.HorizontalSlider android:id = "@+id/slider" android:layout_width = "fill_parent" android:layout_height= "wrap_content" android:max="100" android:layout_centerHorizontal="true" style="?android:attr/progressBarStyleHorizontal" /&gt; &lt;com.astro.mania.classes.HorizontalSlider android:id="@+id/progressBar" android:progressDrawable="@drawable/progressbar" android:layout_width="fill_parent" android:layout_height="24dip" style="?android:attr/progressBarStyleHorizontal" android:indeterminateOnly="false" android:max="100" android:layout_below="@id/slider" android:layout_marginTop="20dip" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Progressbar customised as below:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:id="@android:id/background"&gt; &lt;shape&gt; &lt;gradient android:startColor="#fffffe" android:centerColor="#0b131e" android:centerY="0.75" android:endColor="#0d1522" android:angle="270" /&gt; &lt;/shape&gt; &lt;/item&gt; &lt;item android:id="@android:id/secondaryProgress"&gt; &lt;clip&gt; &lt;shape&gt; &lt;gradient android:startColor="#234" android:centerColor="#234" android:centerY="0.75" android:endColor="#a24" android:angle="270" /&gt; &lt;/shape&gt; &lt;/clip&gt; &lt;/item&gt; &lt;item android:id="@android:id/progress"&gt; &lt;bitmap android:src="@drawable/btn_slide_arrow" android:dither="true" /&gt; &lt;/item&gt; &lt;/layer-list&gt; </code></pre> <p>Finally the activity is like this:</p> <pre><code> public class LensaMania extends Activity { private HorizontalSlider slider, slider2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.activity_lensamania); Log.i("LensaMania", "LensaMania activity started..."); setProgressBarVisibility(true); slider = (HorizontalSlider) this.findViewById(R.id.slider); slider.setOnProgressChangeListener(changeListener); slider2 = (HorizontalSlider) this.findViewById(R.id.progressBar); slider2.setVisibility(View.VISIBLE); slider2.setMax(100); slider2.setProgress(11); slider2.setOnProgressChangeListener(changeListener); } private OnProgressChangeListener changeListener = new OnProgressChangeListener() { public void onProgressChanged(View v, int progress) { setProgress(progress); Log.i("Progress is:", "=&gt;" + progress); } }; } </code></pre> <p>When I run the application and slide progreebar, the image is repeated like image below. I want to have just one image and when I slide it to left want to see just one arrow. How to ask progressbar to don't repeat the image?</p> <p><img src="https://i.stack.imgur.com/ukka7.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload