Skip to content

Commit e6f6f86

Browse files
committed
updated!
updated!
1 parent 613a895 commit e6f6f86

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

android-swipe-views-tabs/app/src/main/java/com/hmkcode/MainActivity.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
package com.hmkcode;
22

33
import android.support.design.widget.TabLayout;
4-
import android.support.v4.app.FragmentActivity;
54
import android.support.v4.view.ViewPager;
65
import android.os.Bundle;
6+
import android.support.v7.app.AppCompatActivity;
7+
78
import com.hmkcode.adapters.MyFragmentPagerAdapter;
89

9-
public class MainActivity extends FragmentActivity {
10+
public class MainActivity extends AppCompatActivity {
1011

1112
MyFragmentPagerAdapter myFragmentPagerAdapter;
1213
ViewPager viewPager;
1314
TabLayout tabLayout;
1415

1516
@Override
1617
protected void onCreate(Bundle savedInstanceState) {
18+
1719
super.onCreate(savedInstanceState);
1820
setContentView(R.layout.activity_main);
1921

22+
2023
viewPager = (ViewPager) findViewById(R.id.viewPager);
24+
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
2125

2226
setPagerAdapter();
2327
setTabLayout();
28+
2429
}
2530

2631
private void setPagerAdapter(){

android-swipe-views-tabs/app/src/main/res/layout/activity_main.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:app="http://schemas.android.com/apk/res-auto"
2+
<android.support.constraint.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:tools="http://schemas.android.com/tools"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
56
android:layout_width="match_parent"
67
android:layout_height="match_parent"
78
tools:context=".MainActivity">
@@ -15,6 +16,8 @@
1516
<android.support.design.widget.TabLayout
1617
android:id="@+id/tabLayout"
1718
android:layout_width="match_parent"
18-
android:layout_height="wrap_content" />
19+
android:layout_height="wrap_content"
20+
app:tabMode="fixed"
21+
app:tabGravity="fill"/>
1922

2023
</android.support.constraint.ConstraintLayout>
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<android.support.constraint.ConstraintLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
android:layout_width="match_parent"
5-
android:layout_height="match_parent">
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent">
66

7-
<TextView
8-
android:layout_width="match_parent"
9-
android:layout_height="match_parent"
10-
android:text="Second Fragment"
11-
android:gravity="center"/>
7+
<TextView
8+
android:layout_width="match_parent"
9+
android:layout_height="match_parent"
10+
android:text="Second Fragment"
11+
android:gravity="center"/>
1212

1313
</android.support.constraint.ConstraintLayout>

0 commit comments

Comments
 (0)