This is probably a simple question, but I really have tried searching here and google with no joy.
I can make listview lists by following the many tutorials on the net. The problem is, they always seem to churn out lists that don't seem similar in appearance to the bulk of the lists I see in apps.
For example, I've attached a screenshot of a menu in the Chainfire3D app. It uses the 'standard' blue dividers, white titles and smaller blue 'description' text for the second line. This style of menu/list is used in many of the market apps I have. Feedly is another example.
Every time I create a listview I get either all white text (or text which is themed by whatever I have used in the layout).
Are there 2 line menus, with white and blue text that are easy to create, because I'm having to specify the colours in XML etc if I want them to look this way.
Also, to get two line listviews I have been using a custom adapter and 2 textviews on top of each other in a layout. I tried a 'simple_list_item_2' and that worked but again it didn't take this 'standard' theme. I'm sure I'm missing something.
Anyone know what?
Ideally, can someone share some code with me that will create a 2 item listviews, ideally (if poss) with a suitable adapter that will allow the running of different activities based on menu items presses. Here's hoping you can help.
The easiest way is to customize your layout.
You can find good examples here or here.
Related
I have the following use case: using a RecyclerView with a custom adapter for listing a simple set of data (each row has something like an icon, a title, and a description). Think of your favorite email or newsfeed app and this is most likely the same visually.
I've reached the point where I need to stylize some key elements from the list quite differently to indicate a special situation - that they are "unread" or that they are "recommended" (e.g. with a different background color, the title font becomes bold, the icon is made larger, the description is hidden, etc).
All of these variations, being purely representation/visual, I have followed the good practices and defined them as 2 different <style> blocks in the values/styles.xml file. However, I am having a hard time applying one of these 2 styles to the row in the onBindViewHolder() method of the adapter, based on some programmatical condition.
(Of course, I can go down the bad way and modify the styling programmatically by manually calling setBackgroundColor() etc on each individual View, but this seems like an ugly workaround for a seemingly trivial problem; additionally, this way we are skipping all of the benefits the .xml styling provides like resolution or locale specific styles).
I have googled this, most of the solutions are using:
1.TabHost with customized style which would cover the separate line between each tab to archive the requirement.
2.On the android developers website, there is a article is using Merge layout to put 2 buttons on top of the background image kind of archive what I want.(http://developer.android.com/resources/articles/layout-tricks-merge.html)
3.What about using button but style the looking like the example below? I don't need the selection, cause each item in the menu will be a button, which takes the user to another page.
I am wondering is there any other solutions apart from these two?
This is something want:
I don't need the menu likes a tab which has selected and unselected, they are better like a button always displaying in certain screen(activity).
Thank you.
You can use simple buttons, and provide any custom background for it. For such simple form as on your screenshot look for this link.
But #Janne write right thing - you should be very careful with transplanting controls from another platforms.
This seems like a really basic task, but after a lot of searching and research, still haven't found a clear answer. I found GridView, but not sure this is how you're supposed to do it.
I've found several apps that have UI elements similar to what I need, for example the top buttons of the android market.
That can easily be accomplished with a horizontal LinearLayout that contains a set of Buttons or ImageButtons. The rest is just styling.
See Hello Linear Layout to get started.
I've seen references on how to SET system colours, but I need to find out how you GET them - how do you find out what they are?
On the Samsung Galaxy S for example, the tab views, ListView highlights when you select an item, and the Summary text line on the preference screen are all blue.
There are many apps which immitate this style and I want to do the same. Obviously I cannot just hard code and set the colour to Blue, as other handsets use different colours.
The question is, is there a way to programmatically find out what colour the Preference Screen Summary Line, Tabs, or ListView selections are, so that you can then set that against a TextView elsewhere in your app?
How do I get the android system colours?
There is an answer to this question, but it is probably not the one you wanted to hear. There is no way to reliably do this. The "selection color" is actually part of a nine-patch image, which is provided on a platform specific basis. Some use the standard orange color, some (Sense) uses green, and others use red. With an exhaustive list of these you might be able to create a mapping from hardware to color, but this is not very effective because new hardware comes out all the time, and some of these phones allow sense to be uninstalled.
The only real thing you can do is to make your buttons consistent within the application itself, which is a hard enough task by itself. If you really have to have a custom item with a selection color (which is common enough), then my advice would be to copy the button resources from the platform of your choice (I like the default sdk resources myself) and then manually set them throughout your application. This way they will always look the same no matter which platform you are on, and so will always match your custom views. Note that this will require you to do more than just buttons. Dialogs and menus also will need to be modified, which is possible, but hard.
Really this is a flaw in the way Android was designed, and it causes a lot of us grief. I wish I had a better answer for you, but I think this is the best we've got.
You can specify colours to elements in your XML layout using the #android:color system variable:
<TextView android:background="#android:color/white" android:textColor="#android:color/black" />
I was wondering if there is a simple way to style a ListView along with it's items like the conversation in android's text message app. There are rounded corners and stuff like that, where I'm not sure how I could implement this myself.
I know that I could look for the source code of it, and try to copy from there, but it's a huge app with a lot of files and that's why I decided to ask first.
Thanks in advance,
Jan Oliver
I don't see any rounded corners in the stock sms app...? Either way, rounded corners are quite easy to do with 9-patch png files. Other than that the styling of the sms app is pretty simple. It contains a couple of TextViews, and one QuickContactBadge, a few different background colors, and that's it.
Here is a good place to start https://dl.google.com/googleio/2010/android-world-of-listview-android.pdf
you are basically going to want to use an Adapter to inflate views you make in the xml editor. Once you have more specific questions we can go into more detail.