我有一个带有无限循环的viewPager,但我想设置一个边框来突出显示当前图像。
在我的主要活动中,我有适配器PageAdapter
和自定义ViewPager
(可点击)。
我认为这很容易,但我需要帮助。
这样的事情:
由于
答案 0 :(得分:0)
> Place image view inside another layout set the background color of > parent layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/border"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="1dp">
<ImageView
android:id="@+id/imageViewImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:foregroundGravity="center_horizontal"/>
</RelativeLayout>
> inside PagerAdapter instantiateItem method when you are setting bitmap > to imageView, also set backgroud color to layout.
final RelativeLayout border = (RelativeLayout) view.findViewById(R.id.border);
border.setBackgroundColor(Color.RED);