Reputation: 748
What effect I want to have is :
number of Bottom Circle indicator must be half of page count when page width is half.
number of Bottom Circle indicator must be as much as page count when page width is full.
also, there is an another request:
page width is acquired by PagerAdapter#getPageWidth()
can anyone give the perfect solution for this? without making two layout files or two adapters?
Here's the whole source code that I have developed to achieve this GIF based activity.
Question Improvement will be accepted.
https://github.com/raghavsatyadev/DemoPort
Upvotes: 6
Views: 1402
Reputation: 10255
In my opinion the best practice in this case is to bind the view[s] to a view group in the adapter. In your adapter you should create a linear layout and add as much children as you want
public Object instantiateItem(ViewGroup container, int position) {
LinearLayout ll = new LinearLayout(context);
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(0,MATCH_PART);
param.weight = 1.0f;
for (int i; i < getChildrenInPage() ; i++) {
MyView myView = View.inflate(context, R.layout.my_layout, null)
myView.bind(getDataForPosition(getChildrenInPage()*position + i))
ll.add(myView, params));
}
}
Upvotes: 1