mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-02 12:17:46 +08:00
fix tablayout's tabindicator's drawing
This commit is contained in:
parent
e78527897f
commit
a2fc876090
@ -28,14 +28,16 @@ int main(int argc,const char*argv[]){
|
||||
layout->setOrientation(LinearLayout::VERTICAL);
|
||||
|
||||
TabLayout* tab=new TabLayout(1280,36);
|
||||
ViewPager*pager=new ViewPager(1280,560);
|
||||
ViewPager* pager=new ViewPager(1280,560);
|
||||
pager->setOffscreenPageLimit(gpAdapter->getCount());
|
||||
pager->setOverScrollMode(View::OVER_SCROLL_ALWAYS);
|
||||
pager->setAdapter(gpAdapter);
|
||||
pager->setBackgroundColor(0xFFF3333);
|
||||
|
||||
tab->setSelectedTabIndicatorColor(0x8000FF00);
|
||||
tab->setSelectedTabIndicatorHeight(4);
|
||||
tab->setTabIndicatorGravity(Gravity::BOTTOM);//TOP/BOTTOM/CENTER_VERTICAL/FILL_VERTICAL
|
||||
tab->setupWithViewPager(pager);
|
||||
layout->addView(tab);
|
||||
layout->addView(tab).setId(1);
|
||||
layout->addView(pager).setId(10);
|
||||
w->addView(layout);
|
||||
w->requestLayout();
|
||||
|
@ -1324,7 +1324,7 @@ void TabLayout::SlidingTabStrip::draw(Canvas& canvas) {
|
||||
int indicatorTop =0;
|
||||
int indicatorBottom=0;
|
||||
switch(mParent->getTabIndicatorGravity()&Gravity::VERTICAL_GRAVITY_MASK){
|
||||
case Gravity::NO_GRAVITY:
|
||||
case Gravity::BOTTOM:
|
||||
indicatorTop =getHeight()-indicatorHeight;
|
||||
indicatorBottom=getHeight();
|
||||
break;
|
||||
@ -1342,9 +1342,16 @@ void TabLayout::SlidingTabStrip::draw(Canvas& canvas) {
|
||||
break;
|
||||
}
|
||||
if (mIndicatorLeft >= 0 && mIndicatorRight > mIndicatorLeft) {
|
||||
canvas.set_color(mSelectedIndicatorColor);
|
||||
canvas.rectangle(mIndicatorLeft,indicatorTop, mIndicatorRight-mIndicatorLeft,indicatorBottom-indicatorTop);
|
||||
canvas.fill();
|
||||
Drawable*d =mParent->mTabSelectedIndicator;
|
||||
if(d){
|
||||
d->setBounds(mIndicatorLeft,indicatorTop, mIndicatorRight-mIndicatorLeft,indicatorBottom-indicatorTop);
|
||||
d->setColorFilter(mSelectedIndicatorColor,PorterDuffMode::SRC_IN);
|
||||
d->draw(canvas);
|
||||
}else{
|
||||
canvas.set_color(mSelectedIndicatorColor);
|
||||
canvas.rectangle(mIndicatorLeft,indicatorTop, mIndicatorRight-mIndicatorLeft,indicatorBottom-indicatorTop);
|
||||
canvas.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user