button second state

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

button second state

Postby andreagosto » Tue Jul 29, 2008 3:44 pm

Hi, i'm beginner.
the Google tutorial is a very good work, but the things to learn are many. Thanks a lot to anddev.org.

My first simple question:
if i set an image for my button, how can i change it like onPressed effect?

regards
User avatar
andreagosto
Freshman
Freshman
 
Posts: 8
Joined: Tue Jul 29, 2008 3:38 pm

Top

Re: button second state

Postby ych.tiger » Wed Jul 30, 2008 1:36 am

andreagosto wrote:Hi, i'm beginner.
the Google tutorial is a very good work, but the things to learn are many. Thanks a lot to anddev.org.

My first simple question:
if i set an image for my button, how can i change it like onPressed effect?

regards


Hi ,your image is too large. you can use ImageButton.setAdjustViewBounds(true) to adjust the image.
User avatar
ych.tiger
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Jul 08, 2008 4:07 am
Location: China

Re: button second state

Postby andreagosto » Wed Jul 30, 2008 8:31 am

ych.tiger wrote:
andreagosto wrote:Hi, i'm beginner.
the Google tutorial is a very good work, but the things to learn are many. Thanks a lot to anddev.org.

My first simple question:
if i set an image for my button, how can i change it like onPressed effect?

regards


Hi ,your image is too large. you can use ImageButton.setAdjustViewBounds(true) to adjust the image.


Thank you, but the problem is another. sorry, maybe is my homemade english..
I have an image associated with button, that's ok. When a press it, i would like that tihs image became a little more dark for example. Just for make in evidence the press action.
User avatar
andreagosto
Freshman
Freshman
 
Posts: 8
Joined: Tue Jul 29, 2008 3:38 pm

Postby michael_g_hu » Thu Aug 07, 2008 9:36 am

you can define it in xml file, you need to read the doc carefully
michael_g_hu
Developer
Developer
 
Posts: 35
Joined: Fri Mar 21, 2008 9:46 am

Postby ych.tiger » Mon Aug 11, 2008 1:14 am

michael_g_hu wrote:you can define it in xml file, you need to read the doc carefully

I haven't solve the problem, and can you tell me how to define the xml files? thanks
User avatar
ych.tiger
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Jul 08, 2008 4:07 am
Location: China

Postby mistapony » Mon Aug 11, 2008 8:31 pm

I am looking for the same answer. I basically have a two custom image files. One is for the default state the other is for the pressed state. What is the best way have the image change when it is pressed and when it is not.

Thanks.
mistapony
Freshman
Freshman
 
Posts: 2
Joined: Wed Jul 30, 2008 8:15 pm

Top

Postby timbobsteve » Tue Sep 30, 2008 4:20 pm

I have the same problem. It's strange... there doesn't appear to be any answers on this anywhere....
you can define it in xml file, you need to read the doc carefully
Really isn't much of a help for beginners.
It is so very bizarre that no solution has been given after such a long time.
Regards,
Timbobsteve
timbobsteve
Freshman
Freshman
 
Posts: 4
Joined: Tue Sep 23, 2008 8:58 pm

Postby cassianotartari » Wed Oct 01, 2008 4:47 am

Maybe these can help you,

First read this:
http://blog.pocketjourney.com/2008/04/30/android-tutorial-image-text-only-buttons/

Second you can add a effect of the onClick like this:
http://www.helloandroid.com/node/155
public class pessoa {
private String nome = "Cassiano Tartari";
private String url = "www.cassianotartari.eng.br"
}
User avatar
cassianotartari
Developer
Developer
 
Posts: 28
Joined: Thu Aug 28, 2008 3:42 pm

Postby andreagosto » Thu Oct 02, 2008 9:52 am

thanks, but is not exactly what I meant. Examples that you linked are appropriate about keyListener, but i think that Android lacks a method onPressed() for its button.

i tried also the use of CompoundButton instead of Button, and this way seem more good approach.
User avatar
andreagosto
Freshman
Freshman
 
Posts: 8
Joined: Tue Jul 29, 2008 3:38 pm

Postby MrSnowflake » Thu Oct 02, 2008 2:10 pm

I do not believe Android has a standard ImageButton, with 3/4 image states. So I believe the only sollution to make this is implement a complete ImageButton yourself. But I haven't tried making image buttons myself, so I don't know really.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby andreagosto » Fri Oct 03, 2008 10:58 am

Hi, i found that also exixts ImageButton.

<ImageButton android:src="@drawable/save" android:id="@+id/buttonSave" android:layout_width="wrap_content" android:layout_height="wrap_content" />
User avatar
andreagosto
Freshman
Freshman
 
Posts: 8
Joined: Tue Jul 29, 2008 3:38 pm

Postby MrSnowflake » Fri Oct 03, 2008 11:00 am

But does it have multiple images? Or is this a normal button with just an image instead of text?
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby andreagosto » Fri Oct 03, 2008 11:06 am

no, it hasn't. But is more close to my intent, the background change at onpressed.
User avatar
andreagosto
Freshman
Freshman
 
Posts: 8
Joined: Tue Jul 29, 2008 3:38 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests