今天我们来做一个自定义的ViewPager并且加上滑动条的效果。
首先,我们把activity_main.xml作为程序的主xml,代码如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".DiscoverMusicFragment" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:background="#FFFFFF" >
<TextView
android:id="@+id/gexingtuijian"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="个性推荐"
android:textColor="#000000"
android:textSize="18dp" />
<TextView
android:id="@+id/gedan"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="歌单"
android:textColor="#000000"
android:textSize="18dp" />
<TextView
android:id="@+id/zhubodiantai"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="主播电台"
android:textColor="#000000"
android:textSize="18dp" />
<TextView
android:id="@+id/paihangbang"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_we