日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > 互聯(lián)網(wǎng) > Android-自定義多標(biāo)題欄組件

Android-自定義多標(biāo)題欄組件

來源:程序員人生   發(fā)布時(shí)間:2014-10-11 08:00:01 閱讀次數(shù):2500次


1如圖,當(dāng)我們的項(xiàng)目有很多子項(xiàng)標(biāo)題的時(shí)候.需要對標(biāo)題實(shí)現(xiàn)左右滑動(dòng).點(diǎn)擊標(biāo)題切換Fragment.當(dāng)滑動(dòng)最左邊的時(shí)候左箭頭消失,滑至右邊的時(shí)候同理.右箭頭消失.


1)因?yàn)槲覀円獙瑒?dòng)實(shí)現(xiàn)彈力效果.故應(yīng)該重寫橫向滑動(dòng)(onScrollChanged()監(jiān)聽器用于對左右滑動(dòng)框顯示控制)

/** * @author Lean */ public class BounceHorizontalScrollView extends HorizontalScrollView { private static final int MAX_X_OVERSCROLL_DISTANCE = 30;// 最大Y軸移動(dòng)尺寸 private Context mContext; private int mMaxYOverscrollDistance; private View mLeftIndicator; private View mRightIndicator; public BounceHorizontalScrollView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; initBounceView(); } public void setIndicator(View leftView,View rightView){ mLeftIndicator=leftView; mRightIndicator=rightView; } private void initBounceView() { final DisplayMetrics metrics = mContext.getResources().getDisplayMetrics(); final float density = metrics.density; mMaxYOverscrollDistance = (int) (density * MAX_X_OVERSCROLL_DISTANCE); } @Override @SuppressLint("NewApi") protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { return super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY, mMaxYOverscrollDistance,maxOverScrollY, isTouchEvent); } @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); if (mLeftIndicator!=null&&mRightIndicator!=null) { if (l<=0) { mLeftIndicator.setVisibility(View.GONE); mRightIndicator.setVisibility(View.VISIBLE); }if (l==180) { mLeftIndicator.setVisibility(View.VISIBLE); mRightIndicator.setVisibility(View.GONE); }else if(l<180&&l>0) { mLeftIndicator.setVisibility(View.VISIBLE); mRightIndicator.setVisibility(View.VISIBLE); } } } }

2.因?yàn)榧^要呈現(xiàn)在界面最上,因此需要重寫FrameLayout.并把箭頭設(shè)置進(jìn)滑動(dòng)界面.

因?yàn)辄c(diǎn)擊后需要對外回調(diào)點(diǎn)擊事件,因此需要把點(diǎn)擊事件的任務(wù)交付給外面的業(yè)務(wù)類.

/** * 健康標(biāo)題 * * @author Lean @date:2014-8-28 */ public class TitleFrameView extends FrameLayout implements OnClickListener{ private View mLeftIndic; private View mRightIndic; private BounceHorizontalScrollView mScrollView; public TitleFrameView(Context context, AttributeSet attrs) { super(context, attrs); } public void setItemClickListener(OnClickListener itemClickListener) { findViewById(R.id.unpay_tv).setOnClickListener(itemClickListener); findViewById(R.id.allpay_tv).setOnClickListener(itemClickListener); findViewById(R.id.unnurse_tv).setOnClickListener(itemClickListener); findViewById(R.id.nursing_tv).setOnClickListener(itemClickListener); findViewById(R.id.allnurse_tv).setOnClickListener(itemClickListener); } public void reShowItemTvColor(View v) { ((TextView)findViewById(R.id.unpay_tv)).setTextColor(0xFFAFBEAD); ((TextView)findViewById(R.id.allpay_tv)).setTextColor(0xFFAFBEAD); ((TextView)findViewById(R.id.unnurse_tv)).setTextColor(0xFFAFBEAD); ((TextView)findViewById(R.id.nursing_tv)).setTextColor(0xFFAFBEAD); ((TextView)findViewById(R.id.allnurse_tv)).setTextColor(0xFFAFBEAD); ((TextView)v).setTextColor(0xFFFFFFFF); } public void initDefault() { findViewById(R.id.unpay_tv).performClick(); } @Override protected void onFinishInflate() { super.onFinishInflate(); mLeftIndic=findViewById(R.id.iv_left); mLeftIndic.setOnClickListener(this); mRightIndic=findViewById(R.id.iv_right); mRightIndic.setOnClickListener(this); mScrollView=(BounceHorizontalScrollView) findViewById(R.id.scroll); mScrollView.setIndicator(mLeftIndic, mRightIndic); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.iv_left: mScrollView.scrollBy(-180,0); break; case R.id.iv_right: mScrollView.scrollBy(180,0); break; default: break; } } }

其代碼的XML如下:

<?xml version="1.0" encoding="utf-8"?> <com.csz.vc.zbhealth.widget.TitleFrameView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#1F9401" > <com.csz.vc.zbhealth.widget.BounceHorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/scroll" android:scrollbars="none" > <LinearLayout android:layout_height="40dip" android:layout_width="match_parent" android:orientation="horizontal" > <TextView android:id="@+id/unpay_tv" android:layout_height="match_parent" android:layout_width="90dip" android:text="@string/unpay" android:textSize="18sp" android:gravity="center" android:textColor="@color/white" android:background="#1F9401" /> <TextView android:id="@+id/allpay_tv" android:layout_height="match_parent" android:layout_width="90dip" android:text="@string/allpay" android:textSize="18sp" android:gravity="center" android:textColor="@color/white" android:background="#1F9401" /> <TextView android:id="@+id/unnurse_tv" android:layout_height="match_parent" android:layout_width="90dip" android:text="@string/unnurse" android:textSize="18sp" android:gravity="center" android:textColor="@color/white" android:background="#1F9401" /> <TextView android:id="@+id/nursing_tv" android:layout_height="match_parent" android:layout_width="90dip" android:text="@string/nursing" android:textSize="18sp" android:gravity="center" android:textColor="@color/white" android:background="#1F9401" /> <TextView android:id="@+id/allnurse_tv" android:layout_height="match_parent" android:layout_width="90dip" android:text="@string/allnurse" android:textSize="18sp" android:gravity="center" android:textColor="@color/white" android:background="#1F9401" /> </LinearLayout> </com.csz.vc.zbhealth.widget.BounceHorizontalScrollView> <ImageView android:id="@+id/iv_left" android:layout_height="match_parent" android:layout_width="30dip" android:layout_gravity="center_vertical|left" android:scaleType="center" android:src="@drawable/arrow_left" /> <ImageView android:id="@+id/iv_right" android:layout_height="match_parent" android:layout_width="30dip" android:layout_gravity="center_vertical|right" android:scaleType="center" android:src="@drawable/arrow_right" /> </com.csz.vc.zbhealth.widget.TitleFrameView>

















生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 国产97视频 | 免费视频国产 | 国产精品亚洲一区二区三区 | 国产精品久久久久久影视 | 九九热视频在线观看 | 精品三区视频 | 国产网红女主播免费视频 | 国产四区 | 日韩亚洲视频 | 精品一二三区在线观看 | 国产激情精品一区二区三区 | 久久久亚洲精品视频 | 在线观看日韩精品 | 五月婷婷六月激情 | 欧美成人手机在线 | 日本福利在线 | 伊人久久在线 | 国产三级网站 | 亚洲精品一级 | 亚洲精品乱码久久久久久麻豆不卡 | 免费看成人 | 亚洲精品美女 | 在线亚洲电影 | 国产精品久久久精品 | 国产精品日韩精品 | 99久久精品国产麻豆演员表 | 亚洲网站在线看 | 操操操日日日 | 久久美女性网 | 91精品福利 | 国产免费一区 | 99爱精品视频 | 精品一二三区 | 日本免费在线一区 | 成年人黄色网址 | 成人久久久精品乱码一区二区三区 | 久久精品123 | 欧美日韩不卡在线 | 国产精品乱码一区二区三区 | 国产成人综合视频 | 久久久网站 |