Combine images and text in a view? what view?

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Combine images and text in a view? what view?

Postby yorgosg » Wed Jan 30, 2008 10:02 am

Hi all,

This is my first post! I did a first attempt with Android, created a TextView, which includes some text. I then created an ImageView to draw an image on it. However, I noticed that whichever View I set with setContentView(), then this is the one shown on screen...
Is there a way to draw BOTH images and text in one view?Maybe combine the two views, like draw one on top of the other?

Another question I have is if there is a way to make my app screen appear in a small window in the main menu screen. Like the way widgets are in windows, the ones that show the weather or other news etc...

Thanks very much in advance. Any help is appreciated, cause I am under a strict deadline!

ps Is there a way to combine a drop down input selection with the previous two views? Cheers!!!!
yorgosg
Developer
Developer
 
Posts: 35
Joined: Wed Jan 30, 2008 9:53 am

Top

Postby plusminus » Wed Jan 30, 2008 10:52 am

Hello yorgosg,

So something like this... is what you want to do, right :?:
Image


So have a look at :src: the code of my Weather-Forecast-Tutorial for the specific snippets (in there, search for 'SingleWeatherInfoView').

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby namsir » Fri Nov 14, 2008 8:10 pm

I think he meant it like this.....i'm still a newbie lol this is the second project i was working on just an example to see how to code in java and xml......

upload your picture in the resdrawable folder and name it "hello"

Main.xml:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:orientation="vertical"
  4.    android:layout_width="wrap_content"
  5.    android:layout_height="wrap_content"
  6.    >
  7.    
  8. <TextView
  9.           android:layout_width="fill_parent"
  10.           android:layout_height="fill_parent"
  11.           android:text = "Helloooooooooooooooooooooooooo"
  12.  
  13. />
  14. <ImageView android:id="@+id/imageview"
  15.           android:layout_width="wrap_content"
  16.           android:layout_height="wrap_content"
  17.           android:src="@drawable/hello"
  18.          
  19. />
  20.  
  21. </LinearLayout>
  22.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4




<activity>.java:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.android.HelloImageText;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.widget.TextView;
  6.  
  7.  
  8. public class helloworldImageText extends Activity {
  9.     /** Called when the activity is first created. */
  10.     @Override
  11.     public void onCreate(Bundle icicle) {
  12.         super.onCreate(icicle);
  13.        
  14.          setContentView(R.layout.main);
  15.        
  16.     }
  17. }
  18.  
  19.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4



This is the result:
Attachments
untitled.JPG
untitled.JPG (60.95 KiB) Viewed 7183 times
namsir
Junior Developer
Junior Developer
 
Posts: 11
Joined: Mon Nov 10, 2008 3:21 pm

Top

Return to General

Who is online

Users browsing this forum: No registered users and 6 guests