1
I would like to develop a ProgressBar
customized to use in my application, but I’m not sure how to do this.
It is necessary to create a sub-class of the ProgressBar
? You can only do it in xml
?
I’d like you to give me a basic example of how to customize this component.
follows my code, without any customization.
File main_activity.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="250dip"
android:layout_height="wrap_content"
android:max="100"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
style="?android:attr/progressBarStyleHorizontal"/>
</RelativeLayout>
Mainactivity class
import android.app.Activity;
import android.os.Bundle;
import android.widget.ProgressBar;
public class MainActivity extends Activity{
private ProgressBar progressBar;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progressBar = (ProgressBar)findViewById(R.id.progressBar);
}
//Mais código
}
What kind of customization do you want to do? A
ProgressBar
Android is very limited, so the chances of you having to create a subclass and override the view are great.– carlosfigueira
The customization I want to do is: change background color when it loads, change edge, take out rounded corners and tals... If you have a better, more customizable component for the same purpose, I would appreciate it if you could tell me :)
– Thomerson Roncally