How do you center a button (or an image for that matter) using Java bridge? I mean, you could create a horizontal arrangement, subtract the button width from the width of the Form, then divide that by 2 and put that value as margins on both sides but that seems really hacky to me. Is there a better way?

Thanks,
Kevin

Search Discussions

  • M. Hossein Amerkashi at Feb 24, 2012 at 4:45 pm
    For Now:
    HorizontalArrangement hr = new HorizontalArrangement(this,
    LENGTH_FILL_PARENT);
    new Label(hr, "", LENGTH_FILL_PARENT, COLOR_NONE);
    Button buttonStart = new Button(this, "I'm centered");
    new Label(hr, "", LENGTH_FILL_PARENT, COLOR_NONE);
  • David W Wolber at Feb 24, 2012 at 7:27 pm
    Hossein, I think you mentioned to me that someone created some Java Bridge
    samples that allow you to create ui objects in the Android xml fashion. Is
    that with a different library?

    Kevin, I'm not suggesting we switch on this as far as building the
    tutorials apps, just want to know if its something that should be explored.

    Dave
    On Fri, Feb 24, 2012 at 8:45 AM, M. Hossein Amerkashi wrote:

    For Now:
    HorizontalArrangement hr = new HorizontalArrangement(this,
    LENGTH_FILL_PARENT);
    new Label(hr, "", LENGTH_FILL_PARENT, COLOR_NONE);
    Button buttonStart = new Button(this, "I'm centered");
    new Label(hr, "", LENGTH_FILL_PARENT, COLOR_NONE);
  • M. Hossein Amerkashi at Feb 26, 2012 at 6:04 pm
    David,

    Bridge does not force to use of bridge components. For example, you can
    create a linear layout with a text label in there like the following:
    setContentView(R.layout.mylaout);
    TextView tv = (TextView) findViewById(R.id.myTextView);

    where firstTextView is defined in your layout xml like:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal">
    <TextView
    android:id="@+id/myTextView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:text="Hello"
    android:textSize="42sp" />
    </LinearLayout>
    On Friday, February 24, 2012 2:27:33 PM UTC-5, David W Wolber wrote:

    Hossein, I think you mentioned to me that someone created some Java Bridge
    samples that allow you to create ui objects in the Android xml fashion. Is
    that with a different library?

    Kevin, I'm not suggesting we switch on this as far as building the
    tutorials apps, just want to know if its something that should be explored.

    Dave
    On Fri, Feb 24, 2012 at 8:45 AM, M. Hossein Amerkashi wrote:

    For Now:
    HorizontalArrangement hr = new HorizontalArrangement(this,
    LENGTH_FILL_PARENT);
    new Label(hr, "", LENGTH_FILL_PARENT, COLOR_NONE);
    Button buttonStart = new Button(this, "I'm centered");
    new Label(hr, "", LENGTH_FILL_PARENT, COLOR_NONE);
  • Ryan Bis at Aug 12, 2012 at 6:31 pm
    Hi David,

    To answer your question, yes there is a java bridge library out there
    which allows the use of the GLE in Eclipse. I put out the Alternate Java
    Bridge library, which has become an Eclipse plugin. It can be used just
    like the original java bridge (coding all UI components), or you can use
    the GLE to drop them in (and "link" to them in code). It makes it much
    easier designing the UI, especially if you are trying to support multiple
    screen sizes. Note that for the AltBridge, resource files go in the
    standard SDK places (images into the drawable folders, sounds into the raw
    folder).

    The plugin makes starting a new project trivial. It includes a new project
    wizard to automatically copy over the jar file, add it to the build path,
    and setup the original Form.

    Wiki:
    http://code.google.com/p/alternate-java-bridge-library/w/list

    DL:
    http://code.google.com/p/alternate-java-bridge-library/downloads/list

    Ryan

    On Friday, February 24, 2012 2:27:33 PM UTC-5, David W Wolber wrote:

    Hossein, I think you mentioned to me that someone created some Java Bridge
    samples that allow you to create ui objects in the Android xml fashion. Is
    that with a different library?

    Kevin, I'm not suggesting we switch on this as far as building the
    tutorials apps, just want to know if its something that should be explored.

    Dave

    On Fri, Feb 24, 2012 at 8:45 AM, M. Hossein Amerkashi <kkas...@gmail.com<javascript:>
    wrote:
    For Now:
    HorizontalArrangement hr = new HorizontalArrangement(this,
    LENGTH_FILL_PARENT);
    new Label(hr, "", LENGTH_FILL_PARENT, COLOR_NONE);
    Button buttonStart = new Button(this, "I'm centered");
    new Label(hr, "", LENGTH_FILL_PARENT, COLOR_NONE);
  • M. Hossein Amerkashi at Feb 25, 2012 at 10:59 pm
    Kevin,
    Functionality added into bridge. Also, added functionality of a Splash
    screen.

    -Hossein
    On Friday, February 24, 2012 4:05:34 AM UTC-5, Kevin Moran wrote:

    How do you center a button (or an image for that matter) using Java
    bridge? I mean, you could create a horizontal arrangement, subtract the
    button width from the width of the Form, then divide that by 2 and put that
    value as margins on both sides but that seems really hacky to me. Is there
    a better way?

    Thanks,
    Kevin
  • M. Hossein Amerkashi at Feb 25, 2012 at 11:01 pm
    Forgot the link to show you how to setup splash:
    See items 4 and 5 of
    http://code.google.com/p/apptomarket/wiki/AiBridgeNightly
    On Saturday, February 25, 2012 5:59:52 PM UTC-5, M. Hossein Amerkashi wrote:

    Kevin,
    Functionality added into bridge. Also, added functionality of a Splash
    screen.

    -Hossein
    On Friday, February 24, 2012 4:05:34 AM UTC-5, Kevin Moran wrote:

    How do you center a button (or an image for that matter) using Java
    bridge? I mean, you could create a horizontal arrangement, subtract the
    button width from the width of the Form, then divide that by 2 and put that
    value as margins on both sides but that seems really hacky to me. Is there
    a better way?

    Thanks,
    Kevin
    On Saturday, February 25, 2012 5:59:52 PM UTC-5, M. Hossein Amerkashi wrote:

    Kevin,
    Functionality added into bridge. Also, added functionality of a Splash
    screen.

    -Hossein
    On Friday, February 24, 2012 4:05:34 AM UTC-5, Kevin Moran wrote:

    How do you center a button (or an image for that matter) using Java
    bridge? I mean, you could create a horizontal arrangement, subtract the
    button width from the width of the Form, then divide that by 2 and put that
    value as margins on both sides but that seems really hacky to me. Is there
    a better way?

    Thanks,
    Kevin
  • Kevin Moran at Feb 26, 2012 at 6:23 am
    Excellent, thanks Hossein.

    Kevin
    On Feb 25, 2012, at 3:01 PM, M. Hossein Amerkashi wrote:

    Forgot the link to show you how to setup splash:
    See items 4 and 5 of http://code.google.com/p/apptomarket/wiki/AiBridgeNightly

    On Saturday, February 25, 2012 5:59:52 PM UTC-5, M. Hossein Amerkashi wrote:
    Kevin,
    Functionality added into bridge. Also, added functionality of a Splash screen.

    -Hossein

    On Friday, February 24, 2012 4:05:34 AM UTC-5, Kevin Moran wrote:
    How do you center a button (or an image for that matter) using Java bridge? I mean, you could create a horizontal arrangement, subtract the button width from the width of the Form, then divide that by 2 and put that value as margins on both sides but that seems really hacky to me. Is there a better way?
    Thanks,
    Kevin


    On Saturday, February 25, 2012 5:59:52 PM UTC-5, M. Hossein Amerkashi wrote:
    Kevin,
    Functionality added into bridge. Also, added functionality of a Splash screen.

    -Hossein

    On Friday, February 24, 2012 4:05:34 AM UTC-5, Kevin Moran wrote:
    How do you center a button (or an image for that matter) using Java bridge? I mean, you could create a horizontal arrangement, subtract the button width from the width of the Form, then divide that by 2 and put that value as margins on both sides but that seems really hacky to me. Is there a better way?
    Thanks,
    Kevin
Discussion Navigation
viewthread | post
Discussion Overview
groupandroid-programming-at-usf @
categoriesandroid
postedFeb 24, '12 at 9:05a
activeAug 12, '12 at 6:31p
posts8
users4
websiteandroid.com

People

Translate

site design / logo © 2021 Grokbase