Android移动终端开发大作业(2)

2025-04-29

scrollToChild(currentPosition, 0);

if (pageListener != null)

{

(currentPosition);

}

}

});

}

private void addTextTab(final int position, String title)

{

TextView tab = new TextView(getContext());

(title);

;

();

addTab(position, tab);

}

private void addIconTab(final int position, int resId)

{

ImageButton tab = new ImageButton(getContext());

(resId);

addTab(position, tab);

}

private void addTab(final int position, View tab)

{

(true);

(new OnClickListener() {

@Override

public void onClick(View v)

{

(position);

}

});

(tabPadding, 0, tabPadding, 0);

(tab, position, shouldExpand expandedTabLayoutParams : defaultTabLayoutParams);

}

private void updateTabStyles()

{

for (int i = 0; i < tabCount; i++)

{

View v = (i);

(tabBackgroundResId);

if (v instanceof TextView)

{

TextView tab = (TextView) v;

, tabTextSize);

(tabTypeface, tabTypefaceStyle);

oString().toUpperCase(locale));

}

}

}

}

}

private void scrollToChild(int position, int offset)

{

if (tabCount == 0) { return; }

int newScrollX = (position).getLeft() + offset;

if (position > 0 || offset > 0)

{

newScrollX -= scrollOffset;

}

if (newScrollX != lastScrollX)

{

lastScrollX = newScrollX;

scrollTo(newScrollX, 0);

}

}

@Override

protected void onDraw(Canvas canvas)

{

(canvas);

if (isInEditMode() || tabCount == 0) { return; }

final int height = getHeight();

etWidth()));

invalidate();

if (delegatePageListener != null)

{

(position, positionOffset, positionOffsetPixels);

}

}

@Override

public void onPageScrollStateChanged(int state)

{

if (state ==

{

scrollToChild(), 0);

}

if (delegatePageListener != null)

{

(state);

}

}

@Override

public void onPageSelected(int position)

{

if (delegatePageListener != null)

{

(position);

}

updateTabStyles();

}

}

public void setIndicatorColor(int indicatorColor)

{

= indicatorColor;

invalidate();

}

public void setIndicatorColorResource(int resId)

{

= getResources().getColor(resId);

invalidate();

}

public int getIndicatorColor()

{

return ;

}

public void setIndicatorHeight(int indicatorLineHeightPx) {

= indicatorLineHeightPx;

invalidate();

}

public int getIndicatorHeight()

{

return indicatorHeight;

}

public void setUnderlineColor(int underlineColor)

{

= underlineColor;

invalidate();

}

public void setUnderlineColorResource(int resId)

{

= getResources().getColor(resId);

invalidate();

}

public int getUnderlineColor()

{

return underlineColor;

}

public void setDividerColor(int piderColor)

{

= piderColor;

invalidate();

}

public void setDividerColorResource(int resId)

{

= getResources().getColor(resId);

invalidate();

}

public int getDividerColor()

{

return piderColor;

}

public void setUnderlineHeight(int underlineHeightPx) {

= underlineHeightPx;

invalidate();

}

public int getUnderlineHeight()

{

return underlineHeight;

}

public void setDividerPadding(int piderPaddingPx) {

= piderPaddingPx;

invalidate();

}

public int getDividerPadding()

{

return piderPadding;

}

public void setScrollOffset(int scrollOffsetPx)

{

= scrollOffsetPx;

invalidate();

}

public int getScrollOffset()

{

return scrollOffset;

}

public void setShouldExpand(boolean shouldExpand) {

= shouldExpand;

requestLayout();

}

public boolean getShouldExpand()

{

return shouldExpand;

}

public boolean isTextAllCaps()

{

return textAllCaps;

}

public void setAllCaps(boolean textAllCaps)

{

= textAllCaps;

}

public void setTextSize(int textSizePx)

{

= textSizePx;

updateTabStyles();

}

public int getTextSize()

{

return tabTextSize;

}

public void setTextColor(int textColor)

{

= textColor;

updateTabStyles();

}

public void setTextColor(int textNormalColor, int textSelectedColor) {

= textNormalColor;

= textSelectedColor;

updateTabStyles();

}

public void setTextColorResource(int resId)

{

= getResources().getColor(resId);

updateTabStyles();

}

public int getTextColor()

{

return tabTextColor;

}

public void setTypeface(Typeface typeface, int style)

{

= typeface;

= style;

updateTabStyles();

}

public void setTabBackground(int resId)

{

= resId;

}

public int getTabBackground()

{

return tabBackgroundResId;

}

public void setTabPaddingLeftRight(int paddingPx)

{

= paddingPx;

updateTabStyles();

}

public int getTabPaddingLeftRight()

{

return tabPadding;

}

@Override

public void onRestoreInstanceState(Parcelable state)

{

SavedState savedState = (SavedState) state;

());

currentPosition = ;

requestLayout();

}

@Override

public Parcelable onSaveInstanceState()

{

Parcelable superState = ();

SavedState savedState = new SavedState(superState);

= currentPosition;

return savedState;

}

static class SavedState extends BaseSavedState

{

int currentPosition;

public SavedState(Parcelable superState) {

super(superState);

}

private SavedState(Parcel in) {

super(in);

currentPosition = ();

}

@Override

public void writeToParcel(Parcel dest, int flags)

{

(dest, flags);

(currentPosition);

}

public static final CREATOR = new () {

@Override

public SavedState createFromParcel(Parcel in)

{

return new SavedState(in);

}

@Override

public SavedState[] newArray(int size)

{

return new SavedState[size];

}

};

}

}

代码3:

*

* Licensed under the Apache License, Version (the "License");

* you may not use this file except in compliance with the License.

* You may obtain a copy of the License at

*

* 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.

*/

public class BitmapUtils implements TaskHandler {

private boolean pauseTask = false;

private boolean cancelAllTask = false;

private final Object pauseTaskLock = new Object();

private Context context;

private BitmapGlobalConfig globalConfig;

private BitmapDisplayConfig defaultDisplayConfig;

etDrawable(resId));

return this;

}

public BitmapUtils configDefaultLoadingImage(Bitmap bitmap) {

(new BitmapDrawable(), bitmap));

return this;

}

public BitmapUtils configDefaultLoadFailedImage(Drawable drawable) {


Android移动终端开发大作业(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:详细中外劳务合同模板

相关阅读
本类排行
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 7

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219