説明: 私はActivity.Drawerをアクティビティに実装しました。利用可能なフラグメントがたくさんあります。私はそれらのアプリケーションのためにmaterialDesignを使用しました。 私はtablayoutをアクティビティに配置するときにスペースを入れません。私は私の断片の中にtablayoutを置くとき、ツールバーとtablayoutの間にスペースを置く。なぜtablayoutとアクションバーは、アンドロイドで断片化したスペースを入れるのですか?
はここに私の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>
であることはここに私の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;
}
}
}
であることはここに私のstyle.xmlここ
<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>
私のV21 /スタイルです。 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>
私はアプリケーションでmaterialDesignパターンを使用しました。画像の下
内部に実装される断片に内部実装されます。上の画像で
私はproblem.Iは、フラグメントの私の活動のようにしたいました。
この問題を解決するのを手伝ってください。
私にお答えください。 –
私はこの問題を理解できませんでした。どのスペース? – ozo
第2画像と第1画像を参照してください。 –