Açıklama: Etkinlik içinde bir navigationDrawer uyguladım.Çok parçalı bölüm var. Bir malzeme kullandım Uygulamam için bunları tasarladım. Etkinlikte sekme eklediğimde, yer kaplamıyor. Benim parçamdan birinin içine sekme yerleştirdiğimde, araç çubuğum ve tablayout arasındaki boşluğu koydu.Neden tablayout ve actionbar android'de parçalara yer açıyor?
İşte benim fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_background"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@drawable/gradient"
android:theme="@style/MyMaterialTheme.AppBarOverlay" >
<android.support.design.widget.TabLayout
android:id="@+id/tabs_schedule"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabTextColor="@color/tab_text"
app:tabSelectedTextColor="@color/tab_text"
app:tabIndicatorColor="#E15E5E"
app:tabIndicatorHeight="3dp"
app:tabTextAppearance="@style/MyTabLayoutTextAppearance"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
İşte benim fragment.java
public class ScheduleSpinner extends Fragment {
View rootView;
TabLayout tabLayout;
ViewPager viewPager;
Toolbar toolbar;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView=inflater.inflate(R.layout.schedule_spinner, container, false);
tabLayout=(TabLayout)rootView.findViewById(R.id.tabs_schedule);
tabLayout.addTab(tabLayout.newTab().setText("Completed"));
tabLayout.addTab(tabLayout.newTab().setText("Upcoming"));
viewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
viewPager.setAdapter(new PagerAdapter
(getFragmentManager(), tabLayout.getTabCount()));
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
return rootView;
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.Score).setVisible(false);
super.onPrepareOptionsMenu(menu);
}
public class PagerAdapter extends FragmentStatePagerAdapter {
int mNumOfTabs;
public PagerAdapter(FragmentManager fm, int NumOfTabs) {
super(fm);
this.mNumOfTabs = NumOfTabs;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
ScheduleCompleted tab1 = new ScheduleCompleted();
return tab1;
case 1:
ScheduleUpcoming tab2 = new ScheduleUpcoming();
return tab2;
default:
return null;
}
}
@Override
public int getCount() {
return mNumOfTabs;
}
}
}
İşte benim style.xml İşte
<resources>
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="MyMaterialTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="MyMaterialTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="MyTabLayoutTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse">
<item name="android:textSize">18sp</item>
<item name="android:textAllCaps">true</item>
</style>
</resources>
benim V21/Stil olmasıdır. xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>
</resources>
Kısacası, uygulamamda bir materialDesign şablonu kullandım. Aşağıdaki resim
fragmanı içine içinde uygulanan bir faaliyet içinde uygulanmaktadır.
Üstü resimde i problem.I fragmanında Etkinliğime gibi istiyorum aldık.Lütfen bu sorunu çözmek için bana yardımcı olun.
Lütfen bana cevap verin. –
Sorunu anlamadım. Hangi alan? – ozo
İkinci resme ve ilk resme bakın. –