A Custom View to indicate multiple fragments with a triangular indicator.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.Jhuku:TriangularCustomView:0.1.1'
}
<com.shuvam.triangleindicator.TriangularIndicator
android:layout_width="match_parent"
android:layout_height="80dp"
app:no_of_sections="5"
android:id="@+id/triangle"
app:set_colour="#253e97"
/>
Create an array of vector image resources from the drawable.
mCustomView = (TriangularIndicator) findViewById(R.id.triangle);
int [] res = { R.drawable.settimerbutton,
R.drawable.settimerbutton,
R.drawable.settimerbutton,
R.drawable.settimerbutton,
R.drawable.settimerbutton};
mCustomView.setResources(res);
mCustomView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
float section = (int)Math.floor(event.getX()*(res.length)/mCustomView.getWidth());
Log.d("Touch event value",""+section);
return false;
}
});
Here section value 0.0 means first tab and so on..