微信PK10平台开发

1、需要在build中添加引用的包 微信PK10平台开发[企俄:2152876294] 网址diguaym.com

compile 'com.android.support:design:25.2.0'
2、布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_height="match_parent"
android:background="@color/background2"
br/>android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background2"
android:orientation="vertical">

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    style="@style/TabLayoutStyle"
    android:layout_width="match_parent"
    android:layout_height="@dimen/dp_50"
    android:layout_marginTop="@dimen/dp_6" />

<android.support.v4.view.ViewPager
    android:id="@+id/vp_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/dp_6" />

</LinearLayout>
注意:在xml中tabs的宽度如果是wrap_content,则会根据文本大小显示多宽

       在xml中tabs的宽度如果是match_parent,则会根据个数平分屏幕的宽度

特别注意:

     要使用TabLayout,Activity主题必须为Theme.AppCompat类型的主题,如:Theme.AppCompat.Light.NoActionBar

     改变选中的背景色和文字大小(如下介绍)

猜你喜欢

转载自blog.51cto.com/13930648/2161797