How to make a lot views scroll together as a single element in android?

爱⌒轻易说出口 提交于 2019-12-13 04:22:21

问题


I have a VideoView which is inside a Framelayout , and has few other elements like imageviews and below is a List View.I want to be able to scroll all the views using single scroll.

The video should get scrolled along with the list view as a single entity !

Have a look at TED Conferences app, here: https://play.google.com/store/apps/details?id=com.ted.android&hl=en

I want to do something similar to that , any ideas & help will be very appreciated. Thank You guys!


回答1:


You can use 3 layouts:

  1. Buttons and VideoView - header
  2. ListView - main layout
  3. another content if needed - footer


ListView lv = (ListView) findViewById(R.id.listView);
View header = getLayoutInflater().inflate(R.layout.header_layout, null);
View footer = getLayoutInflater().inflate(R.layout.foorer_layout, null);
lv.addHeaderView(headerComment);
lv.addFooterView(footerComment);

For tabs functionality you can use TabHost.




回答2:


The TED app I have probably uses a header on their ListView for the "first" item. They might also be using multiple row layouts in the ListView, but if you only want the one row at the top to be different using a header view makes more sense. Check out ListView#addHeaderView()

(Also I wouldn't expect people to download apps to help you with your question. Grab a few screenshots next time.)



来源:https://stackoverflow.com/questions/13241294/how-to-make-a-lot-views-scroll-together-as-a-single-element-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!