안드로이드 라이브러리 Indicator viewpager
인디케이터가 있는 뷰페이저를 만들었음
#사용용도
이미지 배너 제작에 적합, 또는 커스텀 배너 제작에 적합.
#Gradle
repositories { ... maven { url "https://jitpack.io" } }
dependencies { compile 'com.github.roka88:indicatorviewpager:0.0.8' }
#사용법
- CircleIndicatorViewPager를 넣는다.
- Adapter를 만든다.
- CircleIndicatorViewPager에 Adapter를 Set
#Example
<xmp><com.roka.circleviewpager.CircleIndicatorViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="wrap_content"/>
</xmp>
<xmp></xmp><TextView android:id="@+id/number" android:layout_width="match_parent" android:layout_height="200dp" android:gravity="center" android:textSize="20sp" android:background="@color/colorPrimaryDark" android:text="1"/>
<xmp> </xmp><xmp> public class MainActivity extends AppCompatActivity {private Activity mActivity; private CircleIndicatorViewPager mViewpager; private CalendarPagerAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mActivity = this; mViewpager = (CircleIndicatorViewPager) findViewById(R.id.viewpager); List<String> list = new ArrayList<>(); list.add("1"); list.add("2"); list.add("3"); list.add("4"); list.add("5"); list.add("6"); TestPagerAdapter pagerAdapter = new TestPagerAdapter(this, list); mViewpager.setAdapter(pagerAdapter, false); // TODO : 인디케이터 변경 시, 3번째 파라미터는 Indicator를 위에 위치할 것인지 아닌지에 대한 flag //mViewPager.setAdapter(pagerAdapter, R.drawable.xml_indicator, false); // TODO : 페이지를 넘길 때 걸리는 시간 //mViewpager.setDelayPageChange(1000); // TODO : 페이지를 자동으로 넘기는 시간의 텀 //mViewpager.startAutoScroll(1000); // TODO : Scroll이 있는 뷰 내부에서 사용할 시, 높이 사이즈를 직접 지정해줘야함. //DisplayMetrics metrics = this.getResources().getDisplayMetrics(); //int width = metrics.widthPixels; //LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, width / 6 * 3); //mViewpager.setLayoutParams(params); }
} </xmp>
<xmp> public class TestPagerAdapter extends PagerAdapter { private LayoutInflater mInflater; private Activity mActivity; private List mList; public TestPagerAdapter(Activity activity, List list) { this.mActivity = activity; this.mList = list; this.mInflater = activity.getLayoutInflater(); } @Override public void destroyItem(ViewGroup container, int position, Object object) { ((com.roka.circleviewpager.CustomViewPager) container).removeView((View) object); } @Override public int getCount() { return mList.size(); } @Override public Object instantiateItem(ViewGroup view, final int position) { View imageLayout = mInflater.inflate(R.layout.test, view, false); TextView numTv = (TextView) imageLayout.findViewById(R.id.number); numTv.setText(mList.get(position)); ((com.roka.circleviewpager.CustomViewPager) view).addView(imageLayout, 0); return imageLayout; } @Override public boolean isViewFromObject(View view, Object object) { return view.equals(object); } @Override public void restoreState(Parcelable state, ClassLoader loader) { } @Override public Parcelable saveState() { return null; } @Override public void startUpdate(View container) { } } </xmp>#ISSUE
어뎁터의 notifyDataSetChanged() 호출 시 indicator를 갱신하지 못하고 에러가 뜸 어뎁터를 Wrapping할 커스텀 어뎁터를 만들어야하나 고민중#License
Copyright 2016 Roka Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.indicatorviewpager's People
Recommend Projects
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
TensorFlow
An Open Source Machine Learning Framework for Everyone
Django
The Web framework for perfectionists with deadlines.
Laravel
A PHP framework for web artisans
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
Recommend Topics
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
web
Some thing interesting about web. New door for the world.
server
A server is a program made to process requests and deliver data to clients.
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Visualization
Some thing interesting about visualization, use data art
Game
Some thing interesting about game, make everyone happy.
Recommend Org
We are working to build community through open source technology. NB: members must have two-factor auth.
Microsoft
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba
Alibaba Open Source for everyone
D3
Data-Driven Documents codes.
Tencent
China tencent open source team.