目前我正在尝试使用Fragments进行应用程序介绍,我成功创建了它。以下是片段应用程序介绍的屏幕截图,我没有上传所有3个屏幕截图:
第一个问题:如何在其中实现flycopageIndicator:
还有其他简单方法吗?
第二个问题:我在某个应用程序中看到,当我滑动片段时,下一个转换为完成如何做到这一点? 第三个问题:我想模糊我的应用程序的图像。我知道它可能在Java中,但在我的代码中如何?
MainActivity.java
public class MainActivity extends AppCompatActivity {
private TabLayout tabLayout;
private ViewPager viewPager;
private FlycoPageIndicaor mFlycoPageIndicaor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
}
private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment(new OneFragment(), "ONE");
adapter.addFragment(new TwoFragment(), "TWO");
adapter.addFragment(new ThreeFragment(), "THREE");
viewPager.setAdapter(adapter);
}
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager)
{
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}
}
activity_main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/primary"
android:orientation="vertical"
tools:context="com.example.vishal.myapplication.MainActivity">
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"></android.support.v4.view.ViewPager>
<LinearLayout
android:id="@+id/linearLayoutAppInfoButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="0.1"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@android:color/transparent" />
<Button
android:id="@+id/btnGuest"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@android:color/transparent"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Login"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white"
android:textStyle="normal" />
</LinearLayout>
OneFragment.java
public class OneFragment extends android.support.v4.app.Fragment {
public void OneFragment(){
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.one_fragment, container, false);
}}
one_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<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/one_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.vishal.myapplication.OneFragment">
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textColor="@color/white"
android:layout_centerHorizontal="true"
android:layout_marginTop="232dp"
android:id="@+id/textView3"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/image1"
android:scaleType="centerCrop"
android:layout_toStartOf="@+id/textView3"
android:id="@+id/imageView2"
android:layout_alignParentEnd="true"/>
TwoFragment.java和ThreeFragment.java与OneFragment.java具有相同的代码
two_fragment.xml和three_fragment.xml与one_fragment.xml具有相同的代码,具有不同的可绘制图像