Android开发访微博主页
来源:互联网 发布:怎样恢复sd卡数据 编辑:程序博客网 时间:2024/04/30 17:00
需求场景:有个头部,悬停部,下方左右滑动切换内容,再下拉头部内容再次出现,大概是这样
网上有很多这样的源码,我的是参考鸿洋大神的,要原稿说明的请自行百度鸿洋大神的
一、TopicStickyNavLayout :自定义LinearLayout控件,主要是根据当前滑动的位置处理事件分发
public class TopicStickyNavLayout extends LinearLayout { private ScrollListener scrollListener; private Context mContext; private View mTop; private View mNav; private ViewPager mViewPager; private int mActionBarHeight; private int mTopViewHeight; private ViewGroup mInnerScrollView; private boolean isTopHidden = false; private boolean isAddTitleGradient=false; private OverScroller mScroller; private VelocityTracker mVelocityTracker; private int mTouchSlop; private int mMaximumVelocity, mMinimumVelocity; private float mLastY; private boolean mDragging; private boolean isInControl = false; /** * 下拉刷新的回调接口 */ private PullToTopRefreshListener mRefreshListener; /** * 下拉状态 */ public static final int STATUS_PULL_TO_REFRESH = 0; /** * 释放立即刷新状态 */ public static final int STATUS_RELEASE_TO_REFRESH = 1; /** * 正在刷新状态 */ public static final int STATUS_REFRESHING = 2; /** * 刷新完成或未刷新状态 */ public static final int STATUS_REFRESH_FINISHED = 3; /** * 当前是否可以下拉,只有ListView滚动到头的时候才允许下拉 */ private boolean ableToPull; /** * 当前处理什么状态,可选值有STATUS_PULL_TO_REFRESH, STATUS_RELEASE_TO_REFRESH, * STATUS_REFRESHING 和 STATUS_REFRESH_FINISHED */ private int currentStatus = STATUS_REFRESH_FINISHED; private boolean isChange=false; private int screenWidth; public TopicStickyNavLayout(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LinearLayout.VERTICAL); mContext = context; mActionBarHeight = Helper.dip2px(mContext, 48); mScroller = new OverScroller(context); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMaximumVelocity = ViewConfiguration.get(context) .getScaledMaximumFlingVelocity(); mMinimumVelocity = ViewConfiguration.get(context) .getScaledMinimumFlingVelocity(); screenWidth=Base.getScreenWidthPx(mContext); } @Override protected void onFinishInflate() { super.onFinishInflate(); mTop = findViewById(R.id.id_stickynavlayout_topview); mNav = findViewById(R.id.id_stickynavlayout_indicator); View view = findViewById(R.id.id_stickynavlayout_viewpager); if (!(view instanceof ViewPager)) { throw new RuntimeException( "id_stickynavlayout_viewpager show used by ViewPager !"); } mViewPager = (ViewPager) view; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); ViewGroup.LayoutParams params = mViewPager.getLayoutParams(); if(FansPieNewTopicActivity.instance!= null && FansPieNewTopicActivity.instance.isHeadImgExist()){ int height=getMeasuredHeight() - mNav.getMeasuredHeight(); if(height>=screenWidth && !isChange){ params.height =height; isChange=true; } }else{ params.height = getMeasuredHeight()+ mNav.getMeasuredHeight() ; } } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); if(FansPieNewTopicActivity.instance!= null && FansPieNewTopicActivity.instance.isHeadImgExist()){ mTopViewHeight = mTop.getMeasuredHeight() - mActionBarHeight; }else{ mTopViewHeight = mTop.getMeasuredHeight(); } } @Override public boolean dispatchTouchEvent(MotionEvent ev) { int action = ev.getAction(); float y = ev.getY(); switch (action) { case MotionEvent.ACTION_DOWN: mLastY = y; break; case MotionEvent.ACTION_MOVE: float dy = y - mLastY; getCurrentScrollView(); if (mInnerScrollView instanceof ScrollView) { if (mInnerScrollView.getScrollY() == 0 && isTopHidden && dy > 0 && !isInControl) { isInControl = true; ev.setAction(MotionEvent.ACTION_CANCEL); MotionEvent ev2 = MotionEvent.obtain(ev); dispatchTouchEvent(ev); ev2.setAction(MotionEvent.ACTION_DOWN); return dispatchTouchEvent(ev2); } } else if (mInnerScrollView instanceof ListView) { ListView lv = (ListView) mInnerScrollView; View c = lv.getChildAt(lv.getFirstVisiblePosition()); if (!isInControl && c != null && c.getTop() == 0 && isTopHidden && dy > 0) { isInControl = true; ev.setAction(MotionEvent.ACTION_CANCEL); MotionEvent ev2 = MotionEvent.obtain(ev); dispatchTouchEvent(ev); ev2.setAction(MotionEvent.ACTION_DOWN); return dispatchTouchEvent(ev2); } } else if (mInnerScrollView instanceof GridView) { GridView gv = (GridView) mInnerScrollView; View c = gv.getChildAt(gv.getFirstVisiblePosition()); if (!isInControl && c != null && c.getTop() == 0 && isTopHidden && dy > 0) { isInControl = true; ev.setAction(MotionEvent.ACTION_CANCEL); MotionEvent ev2 = MotionEvent.obtain(ev); dispatchTouchEvent(ev); ev2.setAction(MotionEvent.ACTION_DOWN); return dispatchTouchEvent(ev2); } } else if (mInnerScrollView instanceof PullToRefreshListView) { PullToRefreshListView ptrlv = (PullToRefreshListView) mInnerScrollView; ListView lv = ptrlv.getRefreshableView(); View c = lv.getChildAt(lv.getFirstVisiblePosition()); if (!isInControl && c != null && c.getTop() == 0 && isTopHidden && dy > 0) { isInControl = true; ev.setAction(MotionEvent.ACTION_CANCEL); MotionEvent ev2 = MotionEvent.obtain(ev); dispatchTouchEvent(ev); ev2.setAction(MotionEvent.ACTION_DOWN); return dispatchTouchEvent(ev2); } } else if (mInnerScrollView instanceof RecyclerView) { RecyclerView rv = (RecyclerView) mInnerScrollView; if (!isInControl && android.support.v4.view.ViewCompat.canScrollVertically(rv, -1) && isTopHidden && dy > 0) { isInControl = true; ev.setAction(MotionEvent.ACTION_CANCEL); MotionEvent ev2 = MotionEvent.obtain(ev); dispatchTouchEvent(ev); ev2.setAction(MotionEvent.ACTION_DOWN); return dispatchTouchEvent(ev2); } } break; } return super.dispatchTouchEvent(ev); } /** * */ @Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); float y = ev.getY(); switch (action) { case MotionEvent.ACTION_DOWN: mLastY = y; break; case MotionEvent.ACTION_MOVE: float dy = y - mLastY; getCurrentScrollView(); if (Math.abs(dy) > mTouchSlop) { mDragging = true; if (mInnerScrollView instanceof ScrollView) { // 如果topView没有隐藏 // 或sc的scrollY = 0 && topView隐藏 && 下拉,则拦截 if (!isTopHidden || (mInnerScrollView.getScrollY() == 0 && isTopHidden && dy > 0)) { initVelocityTrackerIfNotExists(); mVelocityTracker.addMovement(ev); mLastY = y; return true; } } else if (mInnerScrollView instanceof ListView) { ListView lv = (ListView) mInnerScrollView; View c = lv.getChildAt(lv.getFirstVisiblePosition()); // 如果topView没有隐藏 // 或sc的listView在顶部�&& topView隐藏 && 下拉,则拦截 if (!isTopHidden || (c != null && c.getTop() == 0 && isTopHidden && dy > 0)) { initVelocityTrackerIfNotExists(); mVelocityTracker.addMovement(ev); mLastY = y; return true; } } else if (mInnerScrollView instanceof GridView) { GridView gv = (GridView) mInnerScrollView; View c = gv.getChildAt(gv.getFirstVisiblePosition()); // 如果topView没有隐藏 // 或sc的GridView在顶部�&& topView隐藏 && 下拉,则拦截 if (!isTopHidden || (c != null && c.getTop() == 0 && isTopHidden && dy > 0)) { initVelocityTrackerIfNotExists(); mVelocityTracker.addMovement(ev); mLastY = y; return true; } } else if (mInnerScrollView instanceof PullToRefreshListView) { PullToRefreshListView ptrlv = (PullToRefreshListView) mInnerScrollView; ListView lv = ptrlv.getRefreshableView(); View c = lv.getChildAt(lv.getFirstVisiblePosition()); // 如果topView没有隐藏 // 或sc的PullToRefreshListView在顶部�&& topView隐藏 && 下拉,则拦截 if (!isTopHidden || (c != null && c.getTop() == 0 && isTopHidden && dy > 0 )) { initVelocityTrackerIfNotExists(); mVelocityTracker.addMovement(ev); mLastY = y; return true; } } else if (mInnerScrollView instanceof RecyclerView) { RecyclerView rv = (RecyclerView) mInnerScrollView; if (!isTopHidden || (!android.support.v4.view.ViewCompat.canScrollVertically(rv, -1) && isTopHidden && dy > 0)) { initVelocityTrackerIfNotExists(); mVelocityTracker.addMovement(ev); mLastY = y; return true; } } } break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: mDragging = false; recycleVelocityTracker(); break; } return super.onInterceptTouchEvent(ev); } private void getCurrentScrollView() { int currentItem = mViewPager.getCurrentItem(); PagerAdapter a = mViewPager.getAdapter(); if (a instanceof FragmentPagerAdapter) { FragmentPagerAdapter fadapter = (FragmentPagerAdapter) a; Fragment item = (Fragment) fadapter.instantiateItem(mViewPager, currentItem); mInnerScrollView = (ViewGroup) (item.getView() .findViewById(R.id.id_stickynavlayout_innerscrollview)); } else if (a instanceof FragmentStatePagerAdapter) { FragmentStatePagerAdapter fsAdapter = (FragmentStatePagerAdapter) a; Fragment item = (Fragment) fsAdapter.instantiateItem(mViewPager, currentItem); mInnerScrollView = (ViewGroup) (item.getView() .findViewById(R.id.id_stickynavlayout_innerscrollview)); } else if (a instanceof NewTopicPagerAdapter) { NewTopicPagerAdapter fsAdapter = (NewTopicPagerAdapter) a; Fragment item = (Fragment) fsAdapter.instantiateItem(mViewPager, currentItem); mInnerScrollView = (ViewGroup) (item.getView() .findViewById(R.id.id_stickynavlayout_innerscrollview)); } } @Override public boolean onTouchEvent(MotionEvent event) { initVelocityTrackerIfNotExists(); mVelocityTracker.addMovement(event); int action = event.getAction(); float y = event.getY(); switch (action) { case MotionEvent.ACTION_DOWN: if (!mScroller.isFinished()) mScroller.abortAnimation(); mLastY = y; return true; case MotionEvent.ACTION_MOVE: float dy = y - mLastY; Log.e("TAG", "dy = " + dy + " , y = " + y + " , mLastY = " + mLastY); if (!mDragging && Math.abs(dy) > mTouchSlop) { mDragging = true; } if (mDragging) { scrollBy(0, (int) -dy); // 如果topView隐藏,且上滑动时,则改变当前事件为ACTION_DOWN if (getScrollY() == mTopViewHeight && dy < 0) { event.setAction(MotionEvent.ACTION_DOWN); dispatchTouchEvent(event); isInControl = false; } } mLastY = y; break; case MotionEvent.ACTION_CANCEL: mDragging = false; recycleVelocityTracker(); if (!mScroller.isFinished()) { mScroller.abortAnimation(); } break; case MotionEvent.ACTION_UP: mDragging = false; mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); int velocityY = (int) mVelocityTracker.getYVelocity(); if (Math.abs(velocityY) > mMinimumVelocity) { fling(-velocityY); } recycleVelocityTracker(); break; } return super.onTouchEvent(event); } public void fling(int velocityY) { mScroller.fling(0, getScrollY(), 0, velocityY, 0, 0, 0, mTopViewHeight); invalidate(); } @Override public void scrollTo(int x, int y) { if(y>0 && !isAddTitleGradient){ if(FansPieNewTopicActivity.instance != null){ FansPieNewTopicActivity.instance.setTitleGradient(); isAddTitleGradient=true; } } if (y < 0) { y = 0; } if (y > mTopViewHeight) { y = mTopViewHeight; } if (y != getScrollY()) { super.scrollTo(x, y); } isTopHidden = getScrollY() == mTopViewHeight; if(isTopHidden){ if(FansPieNewTopicActivity.instance != null){ FansPieNewTopicActivity.instance.getFadingActionBarHelper().setActionBarAlpha((int) (255)); } }else{ float progress = (float) getScrollY() / mTopViewHeight; if (progress > 1f) progress = 1f; progress = (1 - (float) Math.cos(progress * Math.PI)) * 0.5f; if(FansPieNewTopicActivity.instance != null && FansPieNewTopicActivity.instance.getFadingActionBarHelper() != null){ FansPieNewTopicActivity.instance.getFadingActionBarHelper().setActionBarAlpha((int) (255*progress)); } } } @Override public void computeScroll() { if (mScroller.computeScrollOffset()) { scrollTo(0, mScroller.getCurrY()); invalidate(); } } private void initVelocityTrackerIfNotExists() { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } } private void recycleVelocityTracker() { if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } } /** * 按钮滑动事件 * * @param listener */ public void setOnScrollListener(ScrollListener listener) { scrollListener = listener; } public interface ScrollListener { public void scrollToTop(boolean flag); } /** * 顶部下拉刷新 */ public void setOnRefreshListener(PullToTopRefreshListener listener){ mRefreshListener=listener; } public interface PullToTopRefreshListener{ public void onRefresh(); }}上面是我项目中的代码,拷过去有些不需要的删除掉好了。
极大可能需要修改为你项目的地方:
1.onInterceptTouchEvent()方法中的if(mInnerScrollView instanceof PullToRefreshListView){}这里的代码改为你项目中用到的类似listview的控件,至于可以参考我的
2.getCurrentScrollView()方法中if(a instanceof NewTopicPagerAdapter){}修改为你的
二、在values文件夹下新建ids_sticky_nav_layout.xml
<?xml version="1.0" encoding="utf-8"?><resources> <item name="id_stickynavlayout_topview" type="id"/> <item name="id_stickynavlayout_viewpager" type="id"/> <item name="id_stickynavlayout_indicator" type="id"/> <item name="id_stickynavlayout_innerscrollview" type="id"/> <item name="id_stickynavlayout_descriptionview" type="id"/></resources>注:如果已经有类似ids的文件,直接放里面就行
三、布局中进行使用
<com.freebox.fanspiedemo.widget.stickylayout.TopicStickyNavLayout android:id="@+id/topic_content_sticky_lay" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--头图--> <LinearLayout android:id="@id/id_stickynavlayout_topview" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <FrameLayout android:id="@+id/topic_head_img_fl" android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/topic_head_img" android:layout_width="match_parent" android:layout_height="wrap_content" android:scaleType="centerCrop" /> <RelativeLayout android:id="@+id/topic_join_tt_rl" android:layout_width="match_parent" android:layout_height="40dp" android:layout_gravity="bottom" android:gravity="center_vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:background="@drawable/shadowdown" android:gravity="center_vertical"> <TextView android:id="@+id/topic_join_txt1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:text="已产生" android:textColor="@color/white" android:textSize="14sp" /> <TextView android:id="@+id/topic_join_txt_count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/y7dColor" android:textSize="18sp" /> <TextView android:id="@+id/topic_join_txt2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="内容" android:textColor="@color/white" android:textSize="14sp" /> </LinearLayout> <LinearLayout android:id="@+id/topic_user_follow_ll" android:layout_width="wrap_content" android:layout_height="25dp" android:layout_alignParentRight="true" android:background="@drawable/left_follow_bg" android:gravity="center_vertical" android:orientation="horizontal" android:visibility="gone"> <ImageView android:id="@+id/topic_user_follow_img" android:layout_width="18dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="4dp" /> <TextView android:id="@+id/topic_user_follow_font" android:layout_width="wrap_content" android:layout_height="20dp" android:layout_gravity="center_vertical" android:layout_marginLeft="16dp" android:layout_marginRight="15dp" android:gravity="center_vertical" /> </LinearLayout> </RelativeLayout> </FrameLayout> <LinearLayout android:id="@+id/topic_no_head_ll" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="6dp" android:gravity="center_vertical" android:orientation="horizontal" android:visibility="gone"> <LinearLayout android:id="@+id/topic_no_admin_ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="10dp" android:gravity="center" android:orientation="vertical"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/topic_no_admin_portrait" android:layout_width="50dp" android:layout_height="50dp" fresco:actualImageScaleType="focusCrop" fresco:placeholderImage="@drawable/img_loading" fresco:placeholderImageScaleType="fitCenter" fresco:roundAsCircle="true" fresco:roundedCornerRadius="180dp" fresco:roundingBorderColor="#FFFAFA" fresco:roundingBorderWidth="0dp" /> <TextView android:id="@+id/topic_no_admin_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:ellipsize="end" android:gravity="center" android:maxEms="5" android:singleLine="true" android:text="管理员" android:textColor="@color/white" android:textSize="12sp" /> </LinearLayout> <LinearLayout android:layout_width="20dp" android:layout_height="match_parent"> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:scaleType="centerCrop" android:src="@drawable/topic_top_yinhao" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center_vertical"> <TextView android:id="@+id/topic_no_admin_description" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:text="信峰哥得永生!峰哥永远最帅" android:textColor="@color/black" android:textSize="16sp" /> </LinearLayout> <LinearLayout android:layout_width="20dp" android:layout_height="match_parent"> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginBottom="10dp" android:scaleType="centerCrop" android:src="@drawable/topic_bottom_yinhao" /> </LinearLayout> </LinearLayout> <!--基本信息--> <LinearLayout android:id="@id/id_stickynavlayout_descriptionview" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <LinearLayout android:id="@+id/description_ll" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginBottom="10dp"> <LinearLayout android:id="@+id/topic_admin_ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:orientation="vertical" android:visibility="gone" > <FrameLayout android:id="@+id/topic_admin_portrait_fl" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginTop="15dp"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/topic_admin_portrait2" android:layout_width="28dp" android:layout_height="28dp" fresco:actualImageScaleType="focusCrop" fresco:placeholderImage="@drawable/avatar_default" fresco:placeholderImageScaleType="centerCrop" fresco:roundAsCircle="true" fresco:roundedCornerRadius="160dp" fresco:roundingBorderColor="#FFFAFA" fresco:roundingBorderWidth="0dp" android:layout_marginRight="6dp" android:layout_gravity="center_vertical" android:visibility="gone" /> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/topic_admin_portrait1" android:layout_width="36dp" android:layout_height="36dp" fresco:actualImageScaleType="focusCrop" fresco:placeholderImage="@drawable/avatar_default" fresco:placeholderImageScaleType="centerCrop" fresco:roundAsCircle="true" fresco:roundedCornerRadius="180dp" fresco:roundingBorderColor="#FFFAFA" fresco:roundingBorderWidth="0dp" android:layout_gravity="center_vertical" android:layout_marginLeft="8dp" android:visibility="gone" /> </FrameLayout> <TextView android:id="@+id/topic_admin_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:ellipsize="end" android:maxEms="5" android:singleLine="true" android:text="管理员" android:textColor="@color/white" android:textSize="10sp" android:layout_marginTop="2dp" android:layout_marginLeft="3dp" android:paddingLeft="2dp" android:paddingRight="2dp" android:background="@drawable/admin_txt_bg"/> </LinearLayout> <LinearLayout android:id="@+id/apply_manager_ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:visibility="gone" android:layout_marginTop="8dp" android:layout_marginLeft="12dp"> <com.freebox.fanspiedemo.widget.GifView android:id="@+id/apply_manager_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> <LinearLayout android:layout_width="25dp" android:layout_height="match_parent" android:layout_marginLeft="12dp"> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:layout_marginTop="16dp" android:scaleType="centerCrop" android:src="@drawable/topic_top_yinhao" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:layout_marginTop="23dp" android:layout_weight="1" android:gravity="center_vertical"> <TextView android:id="@+id/topic_admin_description" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="4dp" android:textColor="#595757" android:textSize="14sp" /> </LinearLayout> <LinearLayout android:layout_width="25dp" android:layout_height="match_parent" android:layout_marginRight="12dp" > <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginBottom="10dp" android:scaleType="centerCrop" android:src="@drawable/topic_bottom_yinhao" /> </LinearLayout> </LinearLayout> </LinearLayout> </LinearLayout><!--悬停内容--> <LinearLayout android:id="@id/id_stickynavlayout_indicator" android:layout_width="match_parent" android:layout_height="43dp" android:layout_gravity="center_vertical" android:background="@color/white" android:orientation="vertical"> <View android:layout_width="match_parent" android:layout_height="1px" android:background="#e9e9e9" /> <LinearLayout android:id="@+id/lay" android:layout_width="match_parent" android:layout_height="40dp" android:orientation="horizontal"> <LinearLayout android:id="@+id/topic_hot_ll" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center"> <TextView android:id="@+id/topic_hot_txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="最热" android:textSize="14sp" android:textColor="@color/tt_author_color"/> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/topic_new_ll" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center"> <LinearLayout android:id="@+id/topic_new_content_ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center"> <TextView android:id="@+id/topic_new_txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="最新" android:textSize="14sp" android:textColor="@color/tt_author_color"/> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/topic_exp_ll" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center"> <LinearLayout android:id="@+id/topic_exp_content_ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center"> <TextView android:id="@+id/topic_exp_txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="贴纸" android:textSize="14sp" android:textColor="@color/tt_author_color"/> </LinearLayout> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/topic_title_line_ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center"> <ImageView android:id="@+id/topic_title_line" android:layout_width="36dp" android:layout_height="2dp" android:background="@color/y7dColor" /> </LinearLayout> <FrameLayout android:layout_width="fill_parent" android:layout_height="1px" android:background="#e9e9e9" /> </LinearLayout> <android.support.v4.view.ViewPager android:id="@id/id_stickynavlayout_viewpager" android:layout_width="match_parent" android:layout_height="match_parent" /> </com.freebox.fanspiedemo.widget.stickylayout.TopicStickyNavLayout>上面主要看<!--xx-->注释的内容改为你项目中的
四、Activity中引用,这里面没什么特别的,按照业务需求声明操作
阅读全文
0 0
- Android开发访微博主页
- Android开发主页框架搭建
- Android 开发Fragment类似微信主页切换
- 快速开发android应用4-使用viewpager+fragment构建主页
- 信息网主页设计开发
- Android 仿QQ主页
- android修改浏览器主页
- 主页隐藏android图标
- 简单web主页面开发
- android开发步步为营之74:生成facebook注册应用主页需要的Key Hashes
- Android开发手机影音篇之Radio Group实现导航主页面
- android 更改浏览器默认主页
- Android 仿QQ主页面
- android修改浏览器默认主页
- android定时回到主页面
- Android 微信主页面
- Android主页动态添加Fragment
- 主页
- 智能排序的实现思路
- 数据结构与算法之二分查找
- hdu 5974 A Simple Math Problem
- view事件分发
- 解决html透明度继承问题
- Android开发访微博主页
- 好文
- forEach与map的使用与区别
- 云栖TechDay|第40期报名:iDST踏上的技术长征
- JavaScript操作Cookie
- 自练题20170716
- ThinkPHP5的数据库和模型用法
- [NOIP提高组2000]进制转换
- 列表