片段中的动画

时间:2018-11-11 00:01:48

标签: animation fragment

我对片段有疑问。我想在我的第一个片段“ Pageone”中实现一个简单的动画淡入

在这里您可以看到我的Fragmentmanagerclass“主页”:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">

<div class="container mt-5">
  <div class="row">

    <div class="col-12" style="background-color: red;">

      <div class="row">

        <div class="divSection3 col-lg-12">
          <div>
            <h6 class="section text-white ml-2 mr-2 ml-lg-0 mr-lg-0">Title 1</h6>
            <div>
              <h5>texto 1</h5>
            </div>
          </div>
        </div>

        <div class="divSection7 col-lg-12">
          <div>
            <h6 class="section text-white ml-2 mr-2 ml-lg-0 mr-lg-0">Title 2</h6>
            <div>
              <h5>texto 2</h5>
            </div>
          </div>
        </div>

        <div class="divSection3 col-lg-12">
          <div>
            <h6 class="section text-white ml-2 mr-2 ml-lg-0 mr-lg-0">Title 3</h6>
            <div>
              <h5>texto 3</h5>
            </div>
          </div>
        </div>

      </div>
    
    </div>

  </div>
</div>

我想将这样的动画添加到“ Pageone”类中,这是第一个片段:

public class Home extends AppCompatActivity {
ViewPager vpager;

@Override

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    vpager= findViewById(R.id.vPager);
    vpager.setAdapter(new setViewadapter(getSupportFragmentManager()));
}
public class setViewadapter extends FragmentPagerAdapter {
    public setViewadapter(FragmentManager fm) {
        super(fm);
    }
    @Override

    public android.support.v4.app.Fragment getItem(int position) {
        if(position==0) {
            return new Pageone();
        }
        else if (position==1){
            return new Pagetwo();
        }
        else if (position==2){
            return new Pagethree();
        }
        else
            return new Likeandfollow();
    }

    @Override

    public int getCount() { return 4; }

没有错误出现,但是启动Pageone片段时应用程序崩溃了。

0 个答案:

没有答案