- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用 Navigation Drawer
在 fragment 之间导航,它们都使用 MainActivity 工具栏,但每个 fragment 都有自己的 TabLayout
和 3 个选项卡,并且在每个选项卡中我使用 RecyclerView
显示不同的文字和图片。
我上次使用的是 Activity 而不是 fragment ,但现在使用抽屉最好使用 fragment 。
我已经到了标签可以工作的地步,但是只要我将 ViewPager
放入并将适配器连接到标签,然后从抽屉中打开新 fragment ,我就会得到一个空指针这里可能是什么问题?
MainActivity.java
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
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(this);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
return id == R.id.action_settings || super.onOptionsItemSelected(item);
}
@Override
public boolean onNavigationItemSelected(MenuItem item) {
int id = item.getItemId();
Fragment fragment;
if (id == R.id.fragment_one) {
fragment = new NewFragment();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, fragment);
ft.commit();
} else if (id == R.id.fragment_two) {
fragment = new NewFragment();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, fragment);
ft.commit();
} else if (id == R.id.fragment_three) {
fragment = new NewFragment();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, fragment);
ft.commit();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
activity_main.xml
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout 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.xcandy.guideforfifa17.MainActivity">
<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" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
NewFragment.java
public class NewFragment extends Fragment {
private RecyclerView mRecyclerView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_fragment_one, container, false);
TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tabs);
tabLayout.addTab(tabLayout.newTab().setText("A"));
tabLayout.addTab(tabLayout.newTab().setText("B"));
tabLayout.addTab(tabLayout.newTab().setText("C"));
final ViewPager viewPager = (ViewPager) view.findViewById(R.id.viewpager);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLayoutManager);
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 view;
}
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:
RecyclerView.Adapter mAdapter = new AdapterOne();
mRecyclerView.setAdapter(mAdapter);
case 1:
mAdapter = new AdapterTwo();
mRecyclerView.setAdapter(mAdapter);
case 2:
mAdapter = new AdapterThree();
mRecyclerView.setAdapter(mAdapter);
default:
return null;
}
}
@Override
public int getCount() {
return mNumOfTabs;
}
}
}
activity_fragment.xml
<android.support.design.widget.CoordinatorLayout 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=".NewFragment">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.design.widget.CoordinatorLayout>
错误日志
--------- beginning of crash
06-23 11:19:56.985 2466-2466/com.candyx.sims E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.candyx.sims, PID: 2466
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference
at com.candyx.sims.BlankFragment.onCreateView(BlankFragment.java:38)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
06-23 11:23:14.912 5839-5873/com.candyx.sims D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[ 06-23 11:23:14.920 5839: 5839 D/ ]
HostConnection::get() New Host Connection established 0xb4125190, tid 5839
06-23 11:23:14.927 5839-5839/com.candyx.sims D/Atlas: Validating map...
06-23 11:23:15.011 5839-5873/com.candyx.sims I/OpenGLRenderer: Initialized EGL, version 1.4
06-23 11:23:15.027 5839-5873/com.candyx.sims D/OpenGLRenderer: Enabling debug mode 0
06-23 11:23:15.039 5839-5873/com.candyx.sims W/EGL_emulation: eglSurfaceAttrib not implemented
06-23 11:23:15.039 5839-5873/com.candyx.sims W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xae838600, error=EGL_SUCCESS
06-23 11:23:16.444 5839-5839/com.candyx.sims W/PathParser: Points are too far apart 4.000000596046461
06-23 11:23:17.342 5839-5839/com.candyx.sims W/PathParser: Points are too far apart 4.000000596046461
06-23 11:23:17.350 5839-5839/com.candyx.sims I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
06-23 11:23:17.369 5839-5839/com.candyx.sims D/AndroidRuntime: Shutting down VM
06-23 11:23:17.369 5839-5839/com.candyx.sims E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.candyx.sims, PID: 5839
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference
at com.candyx.sims.NewFragment.onCreateView(NewFragment.java:38)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
06-23 11:25:16.961 7518-7518/com.candyx.sims W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
06-23 11:25:17.078 7518-7548/com.candyx.sims D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
[ 06-23 11:25:17.081 7518: 7518 D/ ]
HostConnection::get() New Host Connection established 0xb412a1f0, tid 7518
06-23 11:25:17.082 7518-7518/com.candyx.sims D/Atlas: Validating map...
06-23 11:25:17.109 7518-7548/com.candyx.sims I/OpenGLRenderer: Initialized EGL, version 1.4
06-23 11:25:17.126 7518-7548/com.candyx.sims D/OpenGLRenderer: Enabling debug mode 0
06-23 11:25:17.134 7518-7548/com.candyx.sims W/EGL_emulation: eglSurfaceAttrib not implemented
06-23 11:25:17.134 7518-7548/com.candyx.sims W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb41234c0, error=EGL_SUCCESS
06-23 11:25:31.030 7518-7518/com.candyx.sims W/PathParser: Points are too far apart 4.000000596046461
06-23 11:25:32.174 7518-7518/com.candyx.sims W/PathParser: Points are too far apart 4.000000596046461
06-23 11:25:32.187 7518-7518/com.candyx.sims I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
06-23 11:25:32.207 7518-7518/com.candyx.sims D/AndroidRuntime: Shutting down VM
06-23 11:25:32.207 7518-7518/com.candyx.sims E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.candyx.sims, PID: 7518
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference
at com.candyx.sims.NewFragment.onCreateView(NewFragment.java:38)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
最佳答案
查看您的代码后,我发现您忘记在 PagerAdapter 的 getItem 方法中返回您从 FragmentStatePagerAdapter 覆盖的 fragment ,并且在每种情况下都没有 break 语句,因此每次返回了一个空值。
为此,您需要为 ViewPager 中的每个页面创建另一个新 fragment ,或者您可以创建一个可以在 ViewPager 的所有页面中使用的新 fragment 。
您不能在父 fragment 中定义的 View 寻呼机选项卡中使用相同的 recyclerview。
activity_fragment_one.xml
<android.support.design.widget.CoordinatorLayout 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=".NewFragment">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:tabTextAppearance="?android:attr/textAppearanceMedium"
app:tabTextColor="#ffffff"
android:layout_height="?android:actionBarSize"
app:tabMode="fixed"
app:tabGravity="fill"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@android:color/white"/>
</android.support.design.widget.CoordinatorLayout>
我已经修复了您的 fragment 并创建了一个新的 fragment ,您可以在 ViewPager 页面中使用它。
public class NewFragment extends Fragment {
private RecyclerView mRecyclerView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_fragment_one, container, false);
TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tabs);
tabLayout.addTab(tabLayout.newTab().setText("A"));
tabLayout.addTab(tabLayout.newTab().setText("B"));
tabLayout.addTab(tabLayout.newTab().setText("C"));
final ViewPager viewPager = (ViewPager) view.findViewById(R.id.viewpager);
// mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//mRecyclerView.setLayoutManager(mLayoutManager);
viewPager.setAdapter(new PagerAdapter(getFragmentManager(), tabLayout.getTabCount()));
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setupWithViewPager(viewPager);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
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 view;
}
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:
return new FragmentTab();
case 1:
return new FragmentTab();
case 2:
return new FragmentTab();
default:
return null;
}
}
@Override
public int getCount() {
return mNumOfTabs;
}
}
}
View Pager 中每个页面的 FragmentTab(或者您可以根据需要为每个页面创建不同的 fragment )。
public class FragmentTab extends Fragment {
RecyclerView mRecyclerView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_tab, container, false);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(mLayoutManager);
RecyclerView.Adapter mAdapter = new AdapterOne();
mRecyclerView.setAdapter(mAdapter);
return view;
}
}
fragment_tab.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
关于 fragment 内的Android TabLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35058819/
我设法将 Google Maps API 合并到 TabLayout 中,但它有两个问题。一种是应用程序立即询问用户位置,一种是授予权限,但它不会显示新的更新位置。谁能帮帮我吗? 主要 Activit
我已将 tab_layout 放在屏幕底部。我希望它在向上滚动时隐藏并在向下滚动时重新出现。 我试过折叠工具栏布局,但没有用。这是我使用折叠工具栏布局后的代码。建议我一个新的方法,或者指出错误。或者告
是否可以在另一个tablayout 的选项卡内放置一个tablayout?为了更好地解释,我创建了下图。所需的滑动运动如图中所示。 我的主要 Activity XML
我有 viewpager,它有 4 个选项卡,用 tablayout 实现它。因为我想将字体更改为自定义字体,所以我使用了自定义选项卡布局。现在的问题是选定的选项卡文本颜色不会随 tabSelecte
我正在尝试从代码中设置文本大小,因为此选项不存在,有人知道如何实现此目的吗? 我知道可以通过样式实现,但我不能使用样式。 我也尝试过this例如,但它不起作用。 我已经部分成功(某些选项卡获得新的文本
我已经尝试过应该使它工作的解决方案(自定义样式): 文件夹res\values-v21\styles.xml: #3F51
当我开始一个新的选项卡式 Activity 时,我有这个生成的 XML 代码: 我到底应该如何改变它
您好,我已经搜索了实现上图中所示内容的可能方法,但找不到任何帮助。我想创建一个 TabLayout 和底部导航,这样 TabLayout 绑定(bind)到第一个底部图标,第二个底部图标绑定(bind
在我的应用程序中,我有带有两个选项卡的 TabLayout:秒表和计时器。当我在这两个选项卡之间切换并且计时器没有运行时,一切都很好。当我启动计时器时出现问题,指示器动画被延迟。下面的视频演示了此问题
无法解析 TabLayout。我几乎拥有作为解决方案提供的所有依赖项。项目构建了,但仍然无法解决。我正在使用 androidx,但我也尝试过使用 28。 依赖关系: implementation f
我正在使用 Android 设计库中的 TabLayout。我有多个选项卡,每个选项卡在被选择时都有一个操作。所以我有一个属性 startSelection,它执行 tabLayout.getTabA
我从一些设计支持库资源开始,特别是 TabLayout。 这是一个简单的 fragment ,但我无法填充我的 TabLayout, fragment 正常滑动,但我的 TabLayout 没有填充标
我制作了一个 TabLayout 并且工作正常,但我想禁用带有幻灯片的选项卡之间的更改,并使其仅通过单击选项卡名称来更改选项卡有办法做到吗? 最佳答案 只需使用 TabLayout 而不使用 View
在一个项目中,我们将 Material Design 组件的 TabLayout 与 ViewPager 结合使用。有 14 个选项卡,我们希望其中 7 个选项卡在 TabLayout 中一次可见。选
我有以下带有 TabLayout 和 2 个选项卡的 fragment 。每个选项卡都填充一个点来代表 viewpager 内的页面。 如何设置内部有点的 2 个选项卡之间的空间/填充/边距? 我尝试
当我将 Tablayout 拖到布局中时,它卡在左上角。我使用的是android studio 3.6.1。我已经添加了实现 'com.google.android.material:material
更新:我将适配器类修改为以下内容,现在可以正常工作了: public class SectionsPagerAdapter extends FragmentPagerAdapter { R.strin
我在选项卡上方使用底部 TabLayout 和 ViewPager,下面列出了 XML: 当键盘出现时,整个 View 向上推,我只想隐藏底部的 TabLa
有什么方法可以在当前选择的选项卡上设置不同的字体(在 TabLayout 中)? 要使用自定义字体,我使用 Calligraphy,但我正在寻找任何方法来为当前选定的选项卡定义不同的字体。 最佳答案
我想在 app:tabMode="scrollable" 时集中 TabLayout 我的TabLayout 有了那个布局。像这样的 Tablayout(但所有选项卡都左对齐): 如果 app:ta
我是一名优秀的程序员,十分优秀!