0

As Gallery View is deprecated, I'm trying to find a solution to implement an Horizontal List with different views (linearlayouts).

The first option was to use HorizontalScrollView it's fine, but I have to generate all the view by code and all views are stored in memory.

Another option is to use Viewpager, I need to implement my custom pagerAdapter and override the "getPageWidth" method to return a value between 0.0f and 1.0f.

The question is: In layouts I can set the with as a dip value in the XML, but working with PagerAdapter I need to return a float value and I don't know how to calculate this value to work as a dip in layouts.

Thanks.

culebrins
  • 428
  • 9
  • 21
  • Try this to convert to dip http://stackoverflow.com/questions/5591868/android-pixels-to-dips – dasdasd Feb 18 '14 at 15:58
  • The problem is that I have to return a value between 0 and 1. I can't return dip or pixels. – culebrins Feb 18 '14 at 16:34
  • Page adapter holds your fragments. I dont understand if you want to change to size of the fragments or the size of view pager that holds them. – dasdasd Feb 18 '14 at 16:43
  • I use "getPageWidth" to return the size of every fragment inside ViewPager. If I return 1, the fragment will match the parent size. I need to know how to calculate the value to return because I can't use dip or other values as in the layouts. – culebrins Feb 18 '14 at 17:58

0 Answers0