XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context="com.application.nikit.mydoctor.Activity.MedicamentActivity" android:orientation="vertical"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay" > <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> <TextView android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/text_head" android:layout_weight="1" /> </android.support.design.widget.AppBarLayout> <include layout="@layout/content_tablet_pager" android:layout_height="wrap_content" android:layout_width="wrap_content" /> </LinearLayout> content_tablet_pager.xml :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_relative" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.application.nikit.mydoctor.Activity.MedicamentActivity" tools:showIn="@layout/app_bar_tablet_pager"> <FrameLayout 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" tools:context=".Activity.MedicamentActivity" android:id="@+id/root"> <android.support.v4.view.ViewPager android:id="@+id/tablet_view_pager" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/tablet_id" android:layout_width="match_parent" android:layout_height="match_parent" android:headerDividersEnabled="true" android:focusable="false" android:focusableInTouchMode="true" /> </LinearLayout> </android.support.v4.view.ViewPager> </FrameLayout> </RelativeLayout> Activity
public class MedicamentActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { private Fragment mCurrentFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tablet); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Stetho.initializeWithDefaults(this); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener((NavigationView.OnNavigationItemSelectedListener) this); ActiveAndroid.initialize(this); mCurrentFragment = new InfiniteHorizontalTabletFragment(); getSupportFragmentManager().beginTransaction() .replace(android.R.id.content, mCurrentFragment).commit(); ButterKnife.bind(this); } Fragment for ViewPager
public class InfiniteHorizontalTabletFragment extends Fragment implements ViewFactory { private int mBgColor; final String[] tablet_name = new String[]{ "Паратетамол", "Эспумизан", "Милдронат", "Фенибут", "Луналдин", "Анастезин", "Кадионат", "Триметазин", "Рибоксин", "Предуктал МВ", "Валидол", "Моносан" }; final int[] count = { 1, 1, 2, 2, 2, 3, 1, 2, 1, 1, 2, 3 }; final String[] time = new String[]{ "8:20", "8:20", "8:40", "9:20", "10:10", "10:20", "11:05", "12:00", "13:00", "13:00", "15:40", "21:40" }; final String[] time_check = new String[]{ "8:25", "8:30", "8:40", "9:30", "10:25", "10:30", "11:25", "13:00", null, null, null, null }; @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { RelativeLayout layout = (RelativeLayout) inflater.inflate( R.layout.content_tablet_pager, container, false); ViewPager verticalPager = (ViewPager)layout.findViewById(R.id.tablet_view_pager); if(verticalPager.getParent()!=null) ((ViewGroup)verticalPager.getParent()).removeView(verticalPager); // <- fix verticalPager.setAdapter(new InfiniteHorizontalPagerAdapter(this, 0)); verticalPager.setCurrentItem(Constants.START_INDEX); return verticalPager; } @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override public View makeView(int vertical, int horizontal) { ListView listView = new ListView(getActivity()); TabletArrayAdapter arrayAdapter = new TabletArrayAdapter(getActivity(), tablet_name, count, time, time_check); listView.setAdapter(arrayAdapter); listView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { new SweetAlertDialog(getActivity(), SweetAlertDialog.WARNING_TYPE) .setTitleText("Принять " + tablet_name[position-1] + "?") .setConfirmText("Да") .setCancelText("Пропустить") .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { @Override public void onClick(SweetAlertDialog sDialog) { sDialog.dismissWithAnimation(); } }) .show(); } } ); return listView; } } 
Activitywith standard markup. If you do not crawl on the panel, then analyze the differences in the code. Try to bring your markup to its original form. - GHosTAppBarLayoutshould beCoordinatorLayout, notLinearLayout. Watching this example at least - pavlofff