我无法将ViewPager指示器设置为彩色?当我设置背景时,它变得丰富多彩。但我只希望箭头是彩色的?这怎么可以实现?
这是我的ViewPager活动
public class ViewPagerMain extends AppCompatActivity {
ScaleGestureDetector scaleGestureDetector;
ImageView imageView;
Matrix matrix;
ViewPager viewPager;
private ViewPagerArrowIndicator viewPagerArrowIndicator;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_viewpager);
viewPager = (ViewPager) findViewById(R.id.view_pager);
viewPagerArrowIndicator = (ViewPagerArrowIndicator) findViewById(R.id.viewPagerArrowIndicator);
imageView = (ImageView) findViewById(R.id.imageView);
CustomPagerAdapter customPagerAdapter = new CustomPagerAdapter(this);
viewPager.setAdapter(customPagerAdapter);
viewPagerArrowIndicator.bind(viewPager);
viewPagerArrowIndicator.setBackgroundColor(Color.RED);
matrix = new Matrix();
scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());
}
@Override
public boolean onTouchEvent(MotionEvent event) {
scaleGestureDetector.onTouchEvent(event);
return true;
}
private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
@Override
public boolean onScale(ScaleGestureDetector detector) {
float SF = detector.getScaleFactor();
SF = Math.max(0.1f, Math.min(SF, 0.5f));
matrix.setScale(SF, SF);
imageView.setImageMatrix(matrix);
return true;
}
}
}
我的xml文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.sembozdemir.viewpagerarrowindicator.library.ViewPagerArrowIndicator
android:id="@+id/viewPagerArrowIndicator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"></android.support.v4.view.ViewPager>
</com.sembozdemir.viewpagerarrowindicator.library.ViewPagerArrowIndicator>
</RelativeLayout>
I only want to color Arrow only,How than this issue be solved???
答案 0 :(得分:1)
在访问github存储库后,我发现该库正在使用两个png&#39; s作为左右arraow指示符 命名。 ic_arrow_left.png和ic_arrow_right.png因此您可以在项目中包含库项目,只需根据您的要求更改这些项目。
我也发现写在那里你可以改变箭头指示器,提供像png那样的
viewPagerArrowIndicator.setArrowIndicatorRes(R.drawable.custom_left_arrow, R.drawable.custom_right_arrow);