这里把布局文件和核心类代码贴出来,大家一起交流探讨!
为了省事,没加自定义属性,代码中写死了,在此只是提供一些思路。
package com.blemobi.demo.widget; import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; import com.blemobi.demo.R; import com.blemobi.demo.core.LogUtils; import com.blemobi.demo.util.DensityUtil; import com.nineoldandroids.animation.ArgbEvaluator; import com.nineoldandroids.animation.ValueAnimator; import com.nineoldandroids.view.ViewHelper; /** * Created by pengchuan on 2016/4/11. */ public class FlexibleLayout extends RelativeLayout { private int myHeight; private View view0, view1, view2, view3, view4, view5, view7; private LinearLayout view6; private int OPEN_HEIGHT = DensityUtil.dip2px(getContext(), 500); private int CLOSE_HEIGHT = DensityUtil.dip2px(getContext(), 200); private int D_OPEN_CLOSE = OPEN_HEIGHT - CLOSE_HEIGHT; private int EDGE_HEIGHT = DensityUtil.dip2px(getContext(), 350); private float fOffSet0 = DensityUtil.dip2px(getContext(), 180.0F); private float fOffSet1 = DensityUtil.dip2px(getContext(), 118.0F); private float fOffSet2 = DensityUtil.dip2px(getContext(), 70.0F); private float fOffSet3 = DensityUtil.dip2px(getContext(), 80.0F); private float fOffSet4 = DensityUtil.dip2px(getContext(), 40.0F); private View imageChild; private LinearLayout textChild; private ArgbEvaluator evaluator; private int view4Height; public void setSelected(int selected) { this.selected = selected; if(getPickUp() == HeadScrollState.PICK_OPEN){ TextView localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(0)).getChildAt(0); localTextView.setTextColor(getResources().getColor(R.color.otherColor)); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(1)).getChildAt(0); localTextView.setTextColor(getResources().getColor(R.color.otherColor)); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(2)).getChildAt(0); localTextView.setTextColor(getResources().getColor(R.color.otherColor)); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(3)).getChildAt(0); localTextView.setTextColor(getResources().getColor(R.color.otherColor)); TextView textView = (TextView) ((LinearLayout) this.textChild.getChildAt(selected)).getChildAt(0); textView.setTextColor(getResources().getColor(R.color.mineInforBlueColor)); } if(getPickUp() == HeadScrollState.PICK_CLOSE){ TextView localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(0)).getChildAt(1); localTextView.setBackgroundColor(getResources().getColor(R.color.transparent)); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(1)).getChildAt(1); localTextView.setBackgroundColor(getResources().getColor(R.color.transparent)); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(2)).getChildAt(1); localTextView.setBackgroundColor(getResources().getColor(R.color.transparent)); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(3)).getChildAt(1); localTextView.setBackgroundColor(getResources().getColor(R.color.transparent)); TextView textView = (TextView) ((LinearLayout) this.textChild.getChildAt(selected)).getChildAt(1); textView.setBackgroundColor(getResources().getColor(R.color.white)); } } private int selected; public void setScrollListViewListener(ScrollListViewListener scrollListViewListener) { this.scrollListViewListener = scrollListViewListener; } private ScrollListViewListener scrollListViewListener; public FlexibleLayout(Context context) { super(context); } public FlexibleLayout(Context context, AttributeSet attrs) { super(context, attrs); } public FlexibleLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (view4Height == 0) view4Height = view4.getHeight(); } public void setMyHeight(int scrollY) { this.myHeight = (this.OPEN_HEIGHT - scrollY); if (this.myHeight <= this.CLOSE_HEIGHT) this.myHeight = this.CLOSE_HEIGHT; ViewHelper.setTranslationX(this.view0, ScrollUtils.getFloat(measureOffSet(scrollY, this.fOffSet0), 0.0F, this.fOffSet0)); ViewHelper.setTranslationX(this.view1, -ScrollUtils.getFloat(measureOffSet(scrollY, this.fOffSet1), 0.0F, this.fOffSet1)); ViewHelper.setScaleY(this.view1, measureScaleSize()); ViewHelper.setScaleX(this.view1, measureScaleSize()); ViewHelper.setTranslationX(this.view2, ScrollUtils.getFloat(measureOffSet(scrollY, this.fOffSet2), 0.0F, this.fOffSet2)); ViewHelper.setTranslationY(this.view3, -ScrollUtils.getFloat(measureOffSet(scrollY, this.fOffSet3), 0.0F, this.fOffSet3)); ViewHelper.setAlpha(this.view5, measureAlpha()); ViewHelper.setAlpha(this.imageChild, measureAlpha()); ViewHelper.setAlpha(this.view7, measureAlpha()); changeWordColorAndSize(); measureColor(); getLayoutParams().height = this.myHeight; //view4.getLayoutParams().height = getView4Heigh(scrollY); } private int getView4Heigh(int scroll) { return view4Height - (int) (scroll * (view4Height - (CLOSE_HEIGHT - fOffSet4)) / (D_OPEN_CLOSE)); } private void openAnima() { ValueAnimator va = ValueAnimator.ofInt(OPEN_HEIGHT - myHeight, 0); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int scrollY = (int) animation.getAnimatedValue(); LogUtils.i("animation open scrollY: " + scrollY); scrollListViewListener.scrollListView(scrollY); } }); va.setDuration(myHeight - CLOSE_HEIGHT); va.start(); } public HeadScrollState getPickUp() { if (myHeight == CLOSE_HEIGHT) return HeadScrollState.PICK_CLOSE; if (myHeight == OPEN_HEIGHT) return HeadScrollState.PICK_OPEN; return HeadScrollState.PICKING; } private void closeAnima() { ValueAnimator va = ValueAnimator.ofInt(OPEN_HEIGHT - myHeight, D_OPEN_CLOSE); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int scrollY = (int) animation.getAnimatedValue(); scrollListViewListener.scrollListView(scrollY); LogUtils.i("animation close scrollY: " + scrollY); } }); va.setDuration(myHeight - CLOSE_HEIGHT); va.start(); } private void changeWordColorAndSize() { setWordColorAndSize(((Integer) this.evaluator.evaluate(1.0F - measureAlpha(), Integer.valueOf(-6250336), Integer.valueOf(-1))).intValue(), measureSize(), ((Integer) this.evaluator.evaluate(1.0F - measureAlpha(), 0Xff00a7f7, 0Xffffffff)).intValue(), selected); setWordColorAndBackground(scaleXSize(), scaleYSize(), ((Integer) this.evaluator.evaluate(1.0F - measureAlpha(), 0Xff5e6066, 0X00000000)).intValue(), ((Integer) this.evaluator.evaluate(1.0F - measureAlpha(), 0X00000000, 0Xffffffff)).intValue()); } @Override protected void onFinishInflate() { super.onFinishInflate(); this.evaluator = new ArgbEvaluator(); getAllChildView(); } public void getAllChildView() { for (int i = 0; i < getChildCount(); i++) { View view = getChildAt(i); int tag = Integer.parseInt((String) view.getTag()); switch (tag) { case 0: view0 = view; break; case 1: view1 = view; break; case 2: view2 = view; break; case 3: view3 = view; break; case 4: view4 = view; break; case 5: view5 = view; break; case 6: view6 = ((LinearLayout) view); this.imageChild = this.view6.getChildAt(0); this.textChild = ((LinearLayout) this.view6.getChildAt(1)); break; case 7: view7 = view; break; } } } private float measureAlpha() { float f = (this.OPEN_HEIGHT - this.myHeight) * 255.0F / (D_OPEN_CLOSE); return 1.0F - f / 255.0F; } private void measureColor() { this.textChild.setBackgroundColor(16514043); int i = ((Integer) this.evaluator.evaluate(1.0F - measureAlpha(), Integer.valueOf(16514043), Integer.valueOf(805306368))).intValue(); this.textChild.setBackgroundColor(i); } private float measureOffSet(int paramInt, float paramFloat) { return paramInt * paramFloat / (D_OPEN_CLOSE); } private float measureScaleSize() { return 1.0F - 0.2F * (this.OPEN_HEIGHT - this.myHeight) / (D_OPEN_CLOSE); } private float measureSize() { return 12.0F + 3.0F * (this.OPEN_HEIGHT - this.myHeight) / (D_OPEN_CLOSE); } private float scaleXSize() { return 1.0F - 0.5F * (this.OPEN_HEIGHT - this.myHeight) / (D_OPEN_CLOSE); } private float scaleYSize() { return 1.0F - 0.2F * (this.OPEN_HEIGHT - this.myHeight) / (D_OPEN_CLOSE); } private void setWordColorAndSize(int paramInt, float paramFloat, int selectedColor, int selected) { TextView localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(0)).getChildAt(0); localTextView.setTextColor(paramInt); localTextView.setTextSize(paramFloat); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(1)).getChildAt(0); localTextView.setTextColor(paramInt); localTextView.setTextSize(paramFloat); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(2)).getChildAt(0); localTextView.setTextColor(paramInt); localTextView.setTextSize(paramFloat); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(3)).getChildAt(0); localTextView.setTextColor(paramInt); localTextView.setTextSize(paramFloat); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(selected)).getChildAt(0); localTextView.setTextColor(selectedColor); localTextView.setTextSize(paramFloat); } /** * * @param bgColor 背景颜色 */ private void setWordColorAndBackground(float scaleX,float scaleY ,int textColor,int bgColor) { TextView localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(0)).getChildAt(1); localTextView.setTextColor(textColor); ViewHelper.setScaleX(localTextView,scaleX); ViewHelper.setScaleY(localTextView,scaleY); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(1)).getChildAt(1); localTextView.setTextColor(textColor); ViewHelper.setScaleX(localTextView,scaleX); ViewHelper.setScaleY(localTextView,scaleY); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(2)).getChildAt(1); localTextView.setTextColor(textColor); ViewHelper.setScaleX(localTextView,scaleX); ViewHelper.setScaleY(localTextView,scaleY); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(3)).getChildAt(1); localTextView.setTextColor(textColor); ViewHelper.setScaleX(localTextView,scaleX); ViewHelper.setScaleY(localTextView,scaleY); localTextView = (TextView) ((LinearLayout) this.textChild.getChildAt(selected)).getChildAt(1); localTextView.setTextColor(textColor); localTextView.setBackgroundColor(bgColor); } public void autoCloseOrOpen() { if (myHeight == OPEN_HEIGHT || myHeight == CLOSE_HEIGHT) return; if (this.myHeight <= EDGE_HEIGHT) { closeAnima(); } else { openAnima(); } } public interface ScrollListViewListener { void scrollListView(int scroll); } public enum HeadScrollState { PICK_OPEN, PICK_CLOSE, PICKING } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); System.gc(); } }
<?xml version="1.0" encoding="utf-8"?> <com.blemobi.demo.widget.FlexibleLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/flexibleLayout" android:layout_width="match_parent" android:layout_height="500dp" android:clipChildren="false" android:clickable="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/mine_infor_bg" android:orientation="vertical" android:tag="4"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"> <ImageView android:id="@+id/mine_fragment_slide_imv" android:layout_width="44dp" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="15dp" android:src="@drawable/mine_fragment_slide_icon" /> <TextView android:id="@+id/mine_fragment_account_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="@string/personal_setting" android:textColor="@color/white" android:textSize="18sp" /> <LinearLayout android:layout_width="90dp" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:gravity="center" android:orientation="horizontal"> <ImageView android:id="@+id/mine_fragment_search_imv" android:layout_width="44dp" android:layout_height="wrap_content" android:src="@drawable/mine_fragment_search_icon" /> <ImageView android:id="@+id/mine_fragment_setting_imv" android:layout_width="44dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:src="@drawable/mine_fragment_setting_icon" /> </LinearLayout> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"> </RelativeLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical" android:tag="6"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="-10dp" android:orientation="horizontal"> <ImageView android:id="@+id/im_text" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/mine_infor_word_pressed" /> <ImageView android:id="@+id/im_image" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/mine_infor_pic_normal" /> <ImageView android:id="@+id/im_audio" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/mine_infor_video_normal" /> <ImageView android:id="@+id/im_video" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:src="@drawable/mine_infor_voice_normal" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:gravity="center_vertical" android:orientation="horizontal" android:paddingTop="10dp"> <LinearLayout android:id="@+id/text_layout" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <TextView android:id="@+id/text_post" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/mine_infor_word" android:textColor="@color/otherColor" android:textSize="12sp" /> <TextView android:id="@+id/text_post_count" android:layout_width="match_parent" android:gravity="center" android:layout_height="wrap_content" android:textColor="@color/otherColor" android:textSize="12sp" /> </LinearLayout> <LinearLayout android:id="@+id/image_layout" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <TextView android:id="@+id/image_post" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/mine_infor_pic" android:textColor="@color/otherColor" android:textSize="12sp" /> <TextView android:id="@+id/image_post_count" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:textColor="@color/otherColor" android:textSize="12sp" /> </LinearLayout> <LinearLayout android:id="@+id/audio_layout" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <TextView android:id="@+id/audio_post" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/mine_infor_video" android:textColor="@color/otherColor" android:textSize="12sp" /> <TextView android:id="@+id/audio_post_count" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:textColor="@color/otherColor" android:textSize="12sp" /> </LinearLayout> <LinearLayout android:id="@+id/video_layout" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="vertical"> <TextView android:id="@+id/video_post" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/mine_infor_voice" android:textColor="@color/otherColor" android:textSize="12sp" /> <TextView android:id="@+id/video_post_count" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:textColor="@color/otherColor" android:textSize="12sp" /> </LinearLayout> </LinearLayout> </LinearLayout> <com.blemobi.demo.widget.CircleImageView android:id="@+id/mine_fragment_photo" android:layout_width="90dp" android:layout_height="90dp" android:layout_centerHorizontal="true" android:layout_marginTop="60dp" android:src="@drawable/temp" android:tag="1" app:border_color="@android:color/white" app:border_width="2dp" /> <LinearLayout android:id="@+id/mine_add_friend_wrap" android:layout_width="wrap_content" android:layout_height="90dp" android:layout_alignBottom="@id/mine_fragment_photo" android:layout_centerHorizontal="true" android:layout_marginLeft="18dp" android:layout_toRightOf="@id/mine_fragment_photo" android:gravity="center" android:orientation="vertical" android:tag="2"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/mine_edg_icon" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="EDG" android:textColor="@color/white" android:textSize="6sp" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:src="@drawable/mine_vip_plus_icon" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="VIP+" android:textColor="@color/white" android:textSize="6sp" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="90dp" android:layout_alignBottom="@id/mine_fragment_photo" android:layout_centerHorizontal="true" android:layout_marginRight="18dp" android:layout_toLeftOf="@id/mine_fragment_photo" android:gravity="center" android:orientation="vertical" android:tag="0"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/mine_edg_icon" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="EDG" android:textColor="@color/white" android:textSize="6sp" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:src="@drawable/mine_vip_plus_icon" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="VIP+" android:textColor="@color/white" android:textSize="6sp" /> </LinearLayout> <LinearLayout android:id="@+id/name_whole" android:layout_width="180dp" android:layout_height="50dp" android:layout_below="@id/mine_fragment_photo" android:layout_centerHorizontal="true" android:layout_marginTop="20dp" android:gravity="center" android:orientation="horizontal" android:tag="3"> <RelativeLayout android:layout_width="40dp" android:layout_height="40dp" android:layout_marginRight="10dp"> <ImageView android:id="@+id/mine_fragment_level_imv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/mine_fragment_level_icon" /> <TextView android:id="@+id/mine_fragment_level_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignRight="@id/mine_fragment_level_imv" android:layout_marginRight="4dp" android:layout_marginTop="4dp" android:text="23" android:textColor="#ff0000" android:textSize="12sp" /> </RelativeLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="60dp" android:layout_below="@id/mine_fragment_photo" android:layout_centerHorizontal="true" android:gravity="center" android:orientation="vertical" android:tag="7"> <TextView android:id="@+id/mine_fragment_name_tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/mine_infor_name_eg" android:textColor="@color/white" android:textSize="18sp" /> <TextView android:id="@+id/mine_fragment_nickname_tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:gravity="center" android:text="@string/mine_infor_nick_eg" android:textColor="@color/white" android:textSize="12sp" /> </LinearLayout> </LinearLayout> <!-- viewpage--> <LinearLayout android:layout_width="match_parent" android:layout_height="85dp" android:layout_below="@id/name_whole" android:orientation="vertical" android:tag="7"> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal"> <ImageView android:id="@+id/mine_fragment_left_arrow_imv" android:layout_width="40dp" android:layout_height="wrap_content" android:layout_gravity="left|center_vertical" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:src="@drawable/left_arrow" /> <com.blemobi.demo.widget.MyViewPager android:id="@+id/guidePages" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" /> <ImageView android:id="@+id/mine_fragment_right_arrow_imv" android:layout_width="40dp" android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:src="@drawable/right_arrow" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="12dp" android:layout_gravity="bottom" android:gravity="center" android:orientation="horizontal"> <ImageView android:id="@+id/mine_fragment_point_one_imv" android:layout_width="12dp" android:layout_height="wrap_content" android:src="@drawable/mine_fragment_point_selected_icon" /> <ImageView android:id="@+id/mine_fragment_point_two_imv" android:layout_width="12dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:src="@drawable/mine_fragment_point_unselected_icon" /> <ImageView android:id="@+id/mine_fragment_point_three_imv" android:layout_width="12dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:src="@drawable/mine_fragment_point_unselected_icon" /> </LinearLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="44dp" android:layout_below="@id/name_whole" android:layout_marginTop="120dp" android:tag="5"> <LinearLayout android:id="@+id/mine_fragment_friend_layout" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="horizontal"> <TextView android:id="@+id/mine_fragment_friend_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="594" android:textColor="@color/white" android:textSize="12sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:text="@string/mine_infor_friend" android:textColor="@color/white" android:textSize="12sp" /> </LinearLayout> <View android:layout_width="1dp" android:layout_height="match_parent" android:background="@color/white" /> <LinearLayout android:id="@+id/mine_fragment_fans_layout" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="horizontal"> <TextView android:id="@+id/mine_fragment_fans_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="594" android:textColor="@color/white" android:textSize="12sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:text="@string/mine_infor_fans" android:textColor="@color/white" android:textSize="12sp" /> </LinearLayout> <View android:layout_width="1dp" android:layout_height="match_parent" android:background="@color/white" /> <LinearLayout android:id="@+id/mine_fragment_focus_layout" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:orientation="horizontal"> <TextView android:id="@+id/mine_fragment_focus_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="594" android:textColor="@color/white" android:textSize="12sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:text="@string/mine_infor_focus" android:textColor="@color/white" android:textSize="12sp" /> </LinearLayout> </LinearLayout> </com.blemobi.demo.widget.FlexibleLayout>
本文介绍了一个自定义 FlexibleLayout 的实现细节,该布局可以根据滚动位置改变内部元素的位置、大小及颜色等,适用于创建复杂的头部滚动效果。

1937

被折叠的 条评论
为什么被折叠?



