[英]Swipable Linear/Relative Layout
I am relatively a beginner in android. 我是android的初学者。 I was trying to build a similar app as the calculator shown below.
我正在尝试构建一个与如下所示的计算器类似的应用程序。 The problem that I am facing is regarding deciding how to swipe the scientific part of the calculator to the right as shown in the image.
我面临的问题是决定如何如图所示向右滑动计算器的科学部分。 It is certainly not a
ViewPager
, or is it? 当然不是
ViewPager
,不是吗? I cannot conclude how to build this feature. 我无法总结如何构建此功能。 Shall I use a
RelativeLayout
and use my own java code to make it swipable. 我是否应该使用
RelativeLayout
并使用自己的Java代码使其可滑动。 If so then how? 如果是这样,那又如何? Please help me regarding
how to make the Scientific part of the calculator swipable ?
请帮助我有关如何使计算器的科学部分可滑动 ?
If you do not want to use ViewPager
, you can use ViewFlipper
. 如果您不想使用
ViewPager
,则可以使用ViewFlipper
。
You can use ViewPager
. 您可以使用
ViewPager
。 You should create two fragments, for example BasicButtonsFragment
and ScientificButtonsFragment
. 您应该创建两个片段,例如
BasicButtonsFragment
和ScientificButtonsFragment
。 Then you should create a FragmentPagerAdapter
. 然后,您应该创建一个
FragmentPagerAdapter
。
public static class MyAdapter extends FragmentPagerAdapter {
public MyAdapter(FragmentManager fm) {
super(fm);
}
@Override
public int getCount() {
return 2;
}
@Override
public Fragment getItem(int position) {
if (position == 0)
return BasicButtonsFragment.newInstace();
return ScientificButtonsFragment.newInstance();
}
}
Finnaly, set this adapter to your ViewPager
. 最后,将此适配器设置为
ViewPager
。
You can you a DrawerLayout. 您可以使用DrawerLayout。 Check it on the google.
在Google上检查。 I think that is what you are looking for.
我认为这就是您想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.