I am looking to build a button in my Android app which must contain:
A background picture
A picture
Some text
I am coming from iPhone dev and I am a little bit confused by Android development.
While I could addSubView: UIImageView or UILabel to my UIButton, I can't use addView() with a android.widget.Button :(
Does anyone have a solution?
EDIT : Thanks everybody for answers. I forgot to specify I have to do it programmatically, without using XML. I don't know how many element I will display (it depends on RSS).
android:background for background ... remeber that you can build your own 9 patch
android:drawableLeft, android:drawableRight, android:drawableTop, android:drawableBottom to add some picture to the left, right, ... of text
EDIT: i didn't mention ... but i was talking about android.widget.Button
2nd EDIT: after you provide more information i think that all what you need is ListView
check this sample http://esilo.pl/LooserSample.zip (don't take "looser" to yourself, it was sample for another guy)
it showing how to
download a JSON data
store it in db
build ContentProvider for sharing a data
use ContentProvider to take data from db and show it in ListView
dynamic loading images from internet
for simpler sample use your sdk samples like this C:\android\android-sdk-windows\samples\android-8\ApiDemos\src\com\example\android\apis\view\List*.java
if you alrady have code for downloading and storing data from RSS in array extend ArrayAdapter to fit your needs
Most, if not all, of the UI for android is built in the XML. Kind of like the UI builder in Xcode, but not near as advanced. The ADP will let you view the UI you have built in Eclipse, and adjust some basic widget properties.
I believe for what you are trying to do, if I understand right, you need to use an ImageButton widget. This widget allows you to use a complete image as a button. You can also define your own states (button pressed, gain focus, etc) with both the button and image button widgets. You can define a background and add images to both widgets.
More information here
Related
I have to make a new design for an Android App, but I only have to create the visual part (native Android). The app logic would be created by another guy based on what I present to him.
My question is? How would this be managed correctly? Do I have to make the XML's of each layout? How could I show the other person my progress?
What things should I consider when doing this?
Thanks
You need to mock the app first (create a prototype) as suggested by NoChinDeluxe. Then if you guys go ahead and decide to code it, the answer to your problem is separation of responsibilities. As Jeffrey said UI work is not only about layouts, but code as well. What I would suggest is that you and the other guy get together first and define some contracts (interfaces) that will allow you guys to split the work and work in parallel. Therefore, he can create the business logic of the app without worrying about the UI implementation. You, on the other hand, will have to mock that business logic he's implementing at the beginning so it doesn't block your UI work.
you could create layout XML files for all the Activities/screens, using resources (icons, etc as suggested by #NoChinDeluxe). However since you'd want to run the mock app, you might want to also create a "throw-away" Activity that allows you navigate to different screens of the app. Here you can add a number of buttons and when you click on each button, your app shows a specific activity. This way, you will be able to show your colleague all the screens you have created. I hope this helps.
This may not be what you want to hear, but creating Android layouts isn't a design task. They are closely tied to the code, and the design of them is going to depend on how the engineer chooses to implement the app.
Here's an example. You might have a grid with 4 cells. You could use a RelativeLayout, a LinearLayout, or GridLayout, or a GridViewLayout. Which will use choose?
I'd suggest providing your engineer with mockups and graphical assets where required. Let him / her take those and create the layouts. If you want to create layouts as a (visual-only) reference for engineering, great, but it's certainly a non-optimal tool for that task.
Things You will consider when doing visual part:-
You have to work on the resource folder of your application
Layout : All Layout you have to prepare.
Drawable : Images and drawable .xml.
Inside Values folder you will find
dimen.xml : For different devices dimen you can set.
string.xml : You can store string for hint or other purpose.
style.xml : For designing or theme or custom design.
color.xml : Color which are going to used in the application.
I'm working on a project - content listing app.
I would like to know what widget/ component I should use to load images from database and the resources/ references [websites] that I can refer to?
App layout
I wish to have such a layout as shown as above.
It sounds like you want to pull image from a webserver and display then a grid view.
Downloading from the webserver isn't difficult and can be done in a lot of different ways, plus might depend on the rest of your code (But you should make sure to use some type of background threading, to prevent ANR)
Here is a likely better guide on how to setup a grid view.
http://www.mkyong.com/android/android-gridview-example/
as #Anoop Kanyan stated This library looks to be very good for the circle images: https://github.com/hdodenhof/CircleImageView
I have a design Mockup of a remote control with 4 buttons and a Text Display. Now i want to create an Android Activity which looks like this mockup. How can i do this.
I think taking the design image as background for the activity is not the right way to do this (how would i make the buttons on the image clickable, etc...)
Can anybody give me a hint how to start here?
kind regards
You should create 9-patches(or patterns) for each graphic element on your layout for proper layouting on all available devices.
Then apply this patterns to your UI elemnt's(ImageView's, Buttons, TextViews) backgrounds.
Refernces:
http://developer.android.com/tools/help/draw9patch.html - 9-patch documentation
http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html - 9-patch creation
http://developer.android.com/guide/topics/ui/declaring-layout.html - Layouting
You can use your background easily but the rest need to be done in Android.
First : download android sdk
second : create your project
third : code :)
If you're familiar with HTML, that should be kinda similar. You separate the cliclable parts from the background (the buttons), and make them ImageView, setting an onClickListener.
You'll need some Photoshop skills to do that, or ask a buddy designer to do that for you :)
Be careful with multiple screen support, since the background may get trickier to make it look right on every supported screen size.
I'm building an App for Android that already exists for iOS. On iOS, we really like to use the listview grouped style to show details and forms. It is really useful to show details of objects that we don't know how much properties they have before loading it.
I know that Android doesn't have a similar tableview style. And I don't want to use a custom library to recreate it, because I don't want to force an iOS like interface to my Android's users.
But how would you create a consistent Android interface that show similar information? Do you have example for me?
First of all, your instinct to not force iOS style UI onto Android users is correct and I respect you for it.
Android's ListView is roughly the equivalent of iOS's UITableView. There are important differences. For instance, you should never use a ListView inside another scrollable container. If a ListView is in a particular layout, it should (usually) be the only scrollable component. If you want multiple ListViews in a layout, you probably don't want ListViews at all. You should instead use (vertical) LinearLayouts and add the items in order.
Cyril Mottier writes excellent posts on implementing custom behavior for Android's ListView.
If you want to display data in a list then you can use the ListView. Here is a great article about how to use it.
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.