I know that TextView displays text and ImageView displays pictures. However, news content is dynamic and may include multiple texts and images, and the number is variable. How to achieve this?
And like editors, they use an Html editor such as CKEditor to edit news content and save a piece of text in html format in the field. It shouldn’t be possible with TextView and ImageView, right? I haven't seen any control with this function.
Is it made into an H5 page and displayed with WebView? Is there any other plan? How does NetEase News do it?
Of course there are other solutions, you can use RecyclerView/ListView to implement it, and use different layouts for text and pictures
That’s right, it’s h5, including the SegmentFault problem interface, which is also made of h5.
Isn’t this implemented using ListView? ListView combined with adapter can meet your needs
Basically, news pages are implemented in HTML5. This is the advantage of HTML5. Because news editors edit rich text, it is most convenient to display it directly in the form of HTML5
Open the display layout border on your phone and take a look again
A picture displayed by default. The data is displayed after the data is loaded. It is actually a state before the data is loaded. It used to be a blank page
What you are talking about is rich text display. In fact, TextView can do it. It loads html data and parses it.
You can check out this library: https://github.com/Sufficient...
Of course, you can also use WebView
TextView uses rich text function
Spannable
to achieve mixed arrangement of images and textThe display of layout boundaries is more reliable. Since you want to imitate others, you have to know what they are using. Generally speaking, H5 has the best display effect, but it needs to deal with the interaction problem with the native one; then rich text is more difficult to control, and the text There are a series of issues such as styles and picture sizes; finally, the method of matching different item styles through viewtype is also a good method, and there should not be too many reference codes.
Generally used directly
Html5