Sorry I am stupid... you want to use style="?android:buttonStyle" or
style="@android:style/Widget.Button". This is a style resource, which
contains a whole collection of related attributes. For Widget.Button
it looks something like this:
<style name="Widget.Button">
<item name="android:background">@android:drawable/btn_default</
item>
<item name="android:focusable">true</item>
<item name="android:clickable">true</item>
<item name="android:textAppearance">?android:attr/
textAppearanceSmallInverse</item>
<item name="android:textColor">?android:attr/
textColorBrightInverse</item>
<item name="android:gravity">center_vertical|
center_horizontal</item>
</style>
The textAppearance and textColor attributes are relevant to TextView,
so they will be ignored in the LinearLayout.
On Apr 9, 5:19 pm, Mark Wyszomierski <[EMAIL PROTECTED]> wrote:
> Hi hackbod,
>
> I tried with both your variations, with interesting results. Setting
> the following:
>
> android:background="?android:buttonStyle"
>
> gives me a background of an indeterminate progress bar.
>
> Trying:
>
> android:background="@android:style/Widget.Button"
>
> just gives me a runtime error:
>
> "Bimary XML file line #38: Error inflating class
> java.lang.reflect.Constructor"
>
> Any ideas?
>
> Thanks,
> Mark
>
> On Apr 9, 5:31 pm, hackbod <[EMAIL PROTECTED]> wrote:
>
> > If you want the standard button image, use android:background="?
> > android:buttonStyle".
>
> > This says to find the android platform buttonStyle in the current
> > theme, and use that value for the background drawable resource. This
> > is as opposed to android:background="@android:style/Widget.Button",
> > which says to use that explicit resource as the background. (In the
> > default black theme, android:buttonStyle is set to android:style/
> > Widget.Button, so these boil down to the same thing. But by using
> > the ? version, if you change to a different theme or make your own
> > then the layout will get whatever value you specify in it.)
>
> > On Apr 9, 2:12 pm, "Romain Guy" <[EMAIL PROTECTED]> wrote:
>
> > > Note: that code is from the Home application actually.
>
> > > On Wed, Apr 9, 2008 at 2:12 PM, Romain Guy <[EMAIL PROTECTED]> wrote:
> > > > They are application specific. It was just an example.
>
> > > > On Wed, Apr 9, 2008 at 2:09 PM, Mark Wyszomierski <[EMAIL PROTECTED]>
> > > > wrote:
>
> > > > > I see, hate to drag this on, but where are:
>
> > > > > "@drawable/pressed_application_background_static"
>
> > > > > -> pressed_application_background_static
>
> > > > > being defined? Are those standard android images, or do I have to
> > > > make
> > > > > all those myself?
>
> > > > > Thanks,
> > > > > Mark
>
> > > > > On Apr 9, 3:55 pm, "Romain Guy" <[EMAIL PROTECTED]> wrote:
> > > > > > No, it's just a drawable. So you put it in
> > > > > > res/drawable/my_background.xml for instance.
>
> > > > > > On Wed, Apr 9, 2008 at 12:52 PM, Mark Wyszomierski <[EMAIL
> > > > PROTECTED]> wrote:
>
> > > > > > > That looks exactly like what I need.
>
> > > > > > > Where exactly do you create that selector definition though,
> > > > does that
> > > > > > > go in the styles.xml file? Then you somehow set that as the
> > > > background
> > > > > > > of the LinearLayout instance? Right now I've simply defined my
> > > > > > > LinearLayout in an xml file:
>
> > > > > > > <LinearLayout
> > > > xmlns:android="http://schemas.android.com/apk/res/
> > > > > > > android"
> > > > > > > android:layout_width="fill_parent"
> > > > > > > android:layout_height="wrap_content"
> > > > > > > android:orientation="vertical">
>
> > > > > > > .. other stuff
>
> > > > > > > </LinearLayout>
>
> > > > > > > so I just need to add the android:background attribute of the
> > > > above
> > > > > > > definition to point to that selector definition?
>
> > > > > > > Thanks a lot,
> > > > > > > Mark
>
> > > > > > > On Apr 9, 2:27 pm, "Romain Guy" <[EMAIL PROTECTED]> wrote:
> > > > > > > > To do this you will need to give your LinearLayout a
> > > > background that
> > > > > > > > supports states. For instance:
>
> > > > > > > > <selector
> > > > xmlns:android="http://schemas.android.com/apk/res/android">
> > > > > > > > <item android:state_focused="true"
> > > > android:state_pressed="true"
> > > > > > > >
> > > > android:drawable="@drawable/pressed_application_background_static" />
> > > > > > > > <item android:state_focused="false"
> > > > android:state_pressed="true"
> > > > > > > >
> > > > android:drawable="@drawable/pressed_application_background_static" />
> > > > > > > > <item android:state_focused="true"
> > > > > > > >
> > > > android:drawable="@drawable/focused_application_background_static" />
> > > > > > > > <item android:state_focused="false"
> > > > > > > > android:drawable="@android:drawable/empty" />
> > > > > > > > </selector>
>
> > > > > > > > On Wed, Apr 9, 2008 at 11:20 AM, Mark Wyszomierski <[EMAIL
> > > > PROTECTED]> wrote:
>
> > > > > > > > > Hi Romain Guy,
>
> > > > > > > > > The LinearLayout instance is indeed clickable, but is
> > > > there a way to
> > > > > > > > > get it to flash orange like a normal button? I guess
> > > > that's the only
> > > > > > > > > part missing to making it look more button-ish,
>
> > > > > > > > > Thanks,
> > > > > > > > > Mark
>
> > > > > > > > > On Apr 9, 12:39 pm, "Romain Guy" <[EMAIL PROTECTED]>
> > > > wrote:
> > > > > > > > > > Actually there is. Home for instance uses a
> > > > LinearLayout to create the
> > > > > > > > > > buttons on the right. Simply call setClickable() and
> > > > setFocusable() on
> > > > > > > > > > your LinearLayout then add an OnClickListener.
>
> > > > > > > > > > On Wed, Apr 9, 2008 at 9:23 AM, Hielko <[EMAIL
> > > > PROTECTED]> wrote:
>
> > > > > > > > > > > It's possible to implement, but there is no default
> > > > method that can do
> > > > > > > > > > > that for you.
>
> > > > > > > > > > > On Apr 9, 5:39 pm, Mark Wyszomierski <[EMAIL
> > > > PROTECTED]> wrote:
> > > > > > > > > > > > Hi Everyone,
>
> > > > > > > > > > > > Is there any way to make a whole LinearLayout
> > > > instance behave like a
> > > > > > > > > > > > big button, so it flashes when clicked?
>
> > > > > > > > > > > > Similar to an ImageButton, but I'd like to be able
> > > > to set the entire
> > > > > > > > > > > > layout as the button really.
>
> > > > > > > > > > > > Thanks,
> > > > > > > > > > > > Mark
>
> > > > > > > > > > --
> > > > > > > > > > Romain Guywww.curious-creature.org-Hidequotedtext-
>
> > > > > > > > > > - Show quoted text -
>
> > > > > > > > --
> > > > > > > > Romain Guywww.curious-creature.org-Hidequotedtext-
>
> > > > > > > > - Show quoted text -
>
> > > > > > --
> > > > > > Romain Guywww.curious-creature.org-Hidequotedtext -
>
> > > > > > - Show quoted text -
>
> > > > --
> > > > Romain Guy
> > > > www.curious-creature.org
>
> > > --
> > > Romain Guywww.curious-creature.org-Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---