mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-11-30 19:27:49 +08:00
modify numberpicker
This commit is contained in:
parent
28814ed1eb
commit
e92d12e2e7
@ -8,6 +8,12 @@ DECLARE_WIDGET(OptionPicker)
|
||||
OptionPicker::OptionPicker(int w,int h):RelativeLayout(w,h){
|
||||
|
||||
}
|
||||
class PickerInterpolator:public BaseInterpolator{
|
||||
public:
|
||||
float getInterpolation(float input){
|
||||
return 1.f-std::abs(.6f-input);
|
||||
}
|
||||
};
|
||||
|
||||
OptionPicker::OptionPicker(Context*ctx,const AttributeSet&attr):RelativeLayout(ctx,attr){
|
||||
LayoutInflater::from(ctx)->inflate("@layout/optionitem",this);
|
||||
@ -15,7 +21,7 @@ OptionPicker::OptionPicker(Context*ctx,const AttributeSet&attr):RelativeLayout(c
|
||||
mNumberPicker->setVisibility(View::GONE);
|
||||
mNumberPicker->setMinValue(0);
|
||||
mNumberPicker->setMaxValue(5);
|
||||
mNumberPicker->setTextSizeInterpolator(new LinearInterpolator());
|
||||
mNumberPicker->setTextSizeInterpolator(new PickerInterpolator());
|
||||
mText1=(TextView*)findViewById(w9::R::id::text1);
|
||||
mText2=(TextView*)findViewById(w9::R::id::text2);
|
||||
mText1->setText(attr.getString("text1"));
|
||||
|
@ -751,8 +751,6 @@ void NumberPicker::drawVertical(Canvas&canvas){
|
||||
const int selectorWheelColor = (colors==nullptr)? Color::WHITE:colors->getColorForState(StateSet::get(StateSet::VIEW_STATE_ENABLED), Color::WHITE);
|
||||
Color color(selectorWheelColor);
|
||||
Rect rctxt={0,mCurrentScrollOffset,mRight-mLeft,mSelectorElementHeight-mSelectorTextGapHeight/2};
|
||||
Layout txtlayout(mTextSize,mRight-mLeft);
|
||||
//txtlayout.setAlignment(mInputText->getLayoutAlignment());
|
||||
canvas.set_color(selectorWheelColor);
|
||||
canvas.set_font_size(mTextSize);
|
||||
for (int i = 0; i < selectorIndices.size(); i++) {
|
||||
@ -762,14 +760,14 @@ void NumberPicker::drawVertical(Canvas&canvas){
|
||||
// is static and it covers the middle item. Otherwise, if the user starts editing the text
|
||||
// via the/ IME he may see a dimmed version of the old value intermixed with the new one.
|
||||
if(mFontSizeInterpolator){
|
||||
const float interpolator = 1.f -(float)std::abs(i-mMiddleItemIndex)/mMaxSelectorIndices;
|
||||
const float interpolator = (float)(i+1)/selectorIndices.size();
|
||||
const float t = mFontSizeInterpolator->getInterpolation(interpolator);
|
||||
canvas.set_font_size(t*mTextSize);
|
||||
canvas.set_source_rgba(t*color.red(),t*color.green(),t*color.blue(),t*color.alpha());
|
||||
}
|
||||
if ((showSelectorWheel && i != mMiddleItemIndex) ||
|
||||
(i == mMiddleItemIndex && mInputText->getVisibility() != VISIBLE)) {
|
||||
canvas.draw_text(rctxt,scrollSelectorValue,DT_CENTER|DT_VCENTER);
|
||||
canvas.draw_text(rctxt,scrollSelectorValue,mInputText->getGravity());
|
||||
}
|
||||
rctxt.offset(0,mSelectorElementHeight);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user