开发者

Help needed for creating an Android Activity Layout - Screenshot given

开发者 https://www.devze.com 2023-01-19 07:12 出处:网络
I need to create a screen(scrollable) exactly similar to the screenshot shown here. I have no idea regarding the 开发者_开发技巧kind of layout patterns that I should resort to or the widgets that I sh

I need to create a screen(scrollable) exactly similar to the screenshot shown here . I have no idea regarding the 开发者_开发技巧kind of layout patterns that I should resort to or the widgets that I should use.

The data including thumbnail links, is available dynamically.

Experts, kindly help with your valuable suggestions, advices and help.

Looking forward, Regards, Rony


The view used in your screenshot is most probably a customized ListView. Take a look at that.

A useful source I often recommend is the API Demos project.

I'll quickly list the steps you need to do in order to reach your goal ;)

  • Read Android application fundamentals (if not yet done)
  • Watch the I/O session about ListView or review the according slides.
  • Take a look at Cursors and ListAdapters (and possibly ContentProviders). The Notepad tutorial might be useful. You'll need them in order to map the data on your list
  • Check out how to create a custom list row layout. Basically create another layout xml file representing a single list row item; usually a LinearLayout with horizontal orientation (having a thumbnail, text,... in your specific case).
  • Have fun ;)

What helped me personally is to look at the native Android Contacts app's source code. It has a pretty "complex" list with sections, icons etc. Either download the android source or browse it here.


I have worked a lot on Listviews and looking at your screenshot, I would suggest avoiding the use of listviews if you can. If you always have a constant layout, even if its the layout that you showed there in the screenshot then I would do the layout of each element[unique ones only] in an xml file and add them dynamically as and when required. Although I am not sure how you want your layout to be exactly, so this might not be good if your elements can increase in number.


This is a hard question to answer without more information.

Personally, I don't like to use ListView. If you can have the data stored in parallel arrays or something like that, I'd just use a for() loop, adding Buttons, TextViews, etc. to the main layout.


Seeing the screenshot, it's very similar to something I've experienced. I initially used a ListView along with an ArrayAdapter, but in the end, it gave me headaches and had me scratching my head all the time. I'm not Android development expert, but this is how I would do it:

<LinearLayout>
     <!-- Used for the non-scrollable header
          Can be a RelativeLayout if you wish -->
</LinearLayout>

<!-- Scrollable items here -->
<ScrollView>
     <!-- Necessary since ScrollView only accepts one child -->
     <LinearLayout>
          <LinearLayout>
               <!-- This will be the container for the items in your list.
                    You can choose to inflate this layout in your code
                    and use addView to add other child Views you want. -->
               <!-- Views you add here will contain the ImageViews, TextViews
                    for the images and text content -->
          <LinearLayout>
     </LinearLayout>

</ScrollView>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号