I would like to develop a% custom% to use in my application, but I am not sure how to do this.
Is it necessary to create a subclass of ProgressBar
? Can you only do in ProgressBar
?
I would like you to give me a basic example of how to customize this component.
Follow my code, with no customization at all.
Main_activity.xml file
<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
}