Marksss / InfiniteBanner

InfiniteBanner is a view that can automatically or manually scroll in a loop for a banner infinitely, which is very easy to use and is similar to ViewPager. Meanwhile, it not only solves the problem that ViewPager cannot scroll infinitely, but also reuses its child views so that less memory will be token while scrolling.
Apache License 2.0
33 stars 6 forks source link

cannot create wrapper for textView #2

Open Ahmad-b1995 opened 4 years ago

Ahmad-b1995 commented 4 years ago

hi imageViews get centered inside wrapper but not textView, thanks for your great "infinite banner"

Marksss commented 4 years ago

What happens to textview? Can you give me more details?

Ahmad-b1995 commented 4 years ago

Thanks for replying Mark

this is the picture that I want: iPhone 6-7-8 Plus – 79

but I get this result: Screenshot_2020-07-05-11-47-21

and when I turn on "show layout bounds" in developer setting of my phone, it seems that the textView is not in the wrapper and comes after the jammed wrapper to the left of it: Annotation 2020-07-05 115427

here's my makeView code:

` override fun makeView(parent: InfiniteBannerView?): View {

    val textView = TextView(parent!!.context)
    textView.text = "infinite banner"
    textView.textSize = 22.0F
    textView.setTextColor(Color.WHITE)

    return textView}`

I tried padding & centering gravity & ... but no luck. thanks for helping & your banner library

Marksss commented 4 years ago

Try adding these lines inside the mothed makeView:

textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
textView.setGravity(Gravity.CENTER);