GBSlideBar 滑动选择控件

[项目不再维护,有需要的可自行根据需求对源码进行修改] 类似uber的滑动选择工具条

#效果图

animation

#使用

 <so.orion.slidebar.GBSlideBar
        android:id="@+id/gbslidebar"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        app:gbs_anchor_height="25dp"
        app:gbs_anchor_width="25dp"
        app:gbs_background="#e0e0e0"
        app:gbs_paddingBottom="65dp"
        app:gbs_placeholder_width="20dp"
        app:gbs_placeholder_height="20dp"
        app:gbs_paddingLeft="10dp"
        app:gbs_paddingRight="10dp"
        app:gbs_paddingTop="25dp"
        app:gbs_textSize="14sp"
        app:gbs_textColor="#666" />
        
  private GBSlideBar gbSlideBar;
    private SlideAdapter mAdapter;
       gbSlideBar = (GBSlideBar) findViewById(R.id.gbslidebar);

        Resources resources = getResources();
        mAdapter = new SlideAdapter(resources, new int[]{
                R.drawable.btn_tag_selector,
                R.drawable.btn_more_selector,
                R.drawable.btn_reject_selector});
                
        mAdapter.setTextColor(new int[]{
                Color.GREEN,
                Color.BLUE,
                Color.RED
        });
        
        gbSlideBar.setAdapter(mAdapter);
        gbSlideBar.setPosition(2);
        gbSlideBar.setOnGbSlideBarListener(new GBSlideBarListener() {
            @Override
            public void onPositionSelected(int position) {
                Log.d("edanelx","selected "+position);
            }
        });

#引用

 allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }
 dependencies {
            compile 'com.github.edanel:GBSlideBar:0.5'
    }

#其他

参考:android-phased-seek-bar



GBSlideBar 滑动选择控件

[项目不再维护,有需要的可自行根据需求对源码进行修改] 类似uber的滑动选择工具条

#效果图

#使用

 <so.orion.slidebar.GBSlideBar
        android:id="@+id/gbslidebar"
        android:layout_width="wrap_content"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        app:gbs_anchor_height="25dp"
        app:gbs_anchor_width="25dp"
        app:gbs_background="#e0e0e0"
        app:gbs_paddingBottom="65dp"
        app:gbs_placeholder_width="20dp"
        app:gbs_placeholder_height="20dp"
        app:gbs_paddingLeft="10dp"
        app:gbs_paddingRight="10dp"
        app:gbs_paddingTop="25dp"
        app:gbs_textSize="14sp"
        app:gbs_textColor="#666" />
        
  private GBSlideBar gbSlideBar;
    private SlideAdapter mAdapter;
       gbSlideBar = (GBSlideBar) findViewById(R.id.gbslidebar);

    <span class="pl-smi">Resources</span> resources <span class="pl-k">=</span> getResources();
    mAdapter <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-smi">SlideAdapter</span>(resources, <span class="pl-k">new</span> <span class="pl-smi">int</span>[]{
            <span class="pl-smi">R</span><span class="pl-k">.</span>drawable<span class="pl-k">.</span>btn_tag_selector,
            <span class="pl-smi">R</span><span class="pl-k">.</span>drawable<span class="pl-k">.</span>btn_more_selector,
            <span class="pl-smi">R</span><span class="pl-k">.</span>drawable<span class="pl-k">.</span>btn_reject_selector});

    mAdapter<span class="pl-k">.</span>setTextColor(<span class="pl-k">new</span> <span class="pl-smi">int</span>[]{
            <span class="pl-smi">Color</span><span class="pl-c1"><span class="pl-k">.</span>GREEN</span>,
            <span class="pl-smi">Color</span><span class="pl-c1"><span class="pl-k">.</span>BLUE</span>,
            <span class="pl-smi">Color</span><span class="pl-c1"><span class="pl-k">.</span>RED</span>
    });

    gbSlideBar<span class="pl-k">.</span>setAdapter(mAdapter);
    gbSlideBar<span class="pl-k">.</span>setPosition(<span class="pl-c1">2</span>);
    gbSlideBar<span class="pl-k">.</span>setOnGbSlideBarListener(<span class="pl-k">new</span> <span class="pl-smi">GBSlideBarListener</span>() {
        <span class="pl-k">@Override</span>
        <span class="pl-k">public</span> <span class="pl-k">void</span> <span class="pl-en">onPositionSelected</span>(<span class="pl-k">int</span> <span class="pl-v">position</span>) {
            <span class="pl-smi">Log</span><span class="pl-k">.</span>d(<span class="pl-s"><span class="pl-pds">&#34;</span>edanelx<span class="pl-pds">&#34;</span></span>,<span class="pl-s"><span class="pl-pds">&#34;</span>selected <span class="pl-pds">&#34;</span></span><span class="pl-k">+</span>position);
        }
    });</pre></div>

引用

 allprojects {
        repositories {
            …
            maven { url "https://jitpack.io&#34; }
        }
    }
 dependencies {
            compile 'com.github.edanel:GBSlideBar:0.5'
    }

#其他

参考: android-phased-seek-bar




相关问题推荐