TOP

仿微信底部TAG完美漸變(一)
2017-10-12 11:28:38 】 瀏覽:10947
Tags:

viewpager+fragment仿微信底部TAG完美漸變,在圖片漸變的同時字的顏色也在變,注意,是漸變哦!

效果圖:

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:zhy="http://schemas.android.com/apk/res/com.Sing.weixin"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <android.support.v4.view.ViewPager
        android:id="@+id/id_viewpager"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >
    </android.support.v4.view.ViewPager>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="60dp"
        android:background="@drawable/tabbg"
        android:orientation="horizontal" >
        <com.Sing.weixin.ChangeColorIconWithTextView
            android:id="@+id/id_indicator_one"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:padding="5dp"
            zhy:icon="@drawable/ic_menu_start_conversation"
            zhy:text="@string/tab_one"
            zhy:text_size="12sp" />
        <com.Sing.weixin.ChangeColorIconWithTextView
            android:id="@+id/id_indicator_two"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:padding="5dp"
            zhy:icon="@drawable/ic_menu_friendslist"
            zhy:text="@string/tab_two"
            zhy:text_size="12sp" />
    </LinearLayout>
</LinearLayout>

MainActivity.java

package com.Sing.weixin;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewConfiguration;
@SuppressLint("NewApi")
public class MainActivity extends FragmentActivity implements
		OnPageChangeListener, OnClickListener {
	private ViewPager mViewPager;
	// 選項卡一Fragment
	private FrgReturnVisit returnVisit;
	// 選項卡一Fragment
	private FrgMicroVisit microVisit;
	private List<ChangeColorIconWithTextView> mTabIndicator = new ArrayList<ChangeColorIconWithTextView>();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		setOverflowShowingAlways();
		mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
		mViewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
		initTabIndicator();
		mViewPager.setOnPageChangeListener(this);
 	}
	pr  
		

請關注公眾號獲取更多資料



首頁 上一頁 1 2 3 4 下一頁 尾頁 1/4/4
】【打印繁體】【】【】 【】【】【】 【關閉】 【返回頂部
上一篇android 自定義滑動按鈕 下一篇Genymotion 下載安裝常見錯誤一條..