1

I want to implement a running text on the watch, so that a line of text would move from the right to the left.

The best way to do so for me would be to create a TextView with the width of the screen, set the text there with the maximum paddingLeft and then decrement the padding, so that the text (a few words) would move from the right to the left.

So my question is: is it possible to dynamically change the attribute "paddingLeft" of the TextView?

<TextView
    android:id="@+id/scrollingText"
    android:layout_width="@dimen/smart_watch_2_control_width"
    android:layout_height="wrap_content"

    android:paddingRight="@dimen/smart_watch_2_control_width"

    android:text="Hello world!"

    />

Maybe something like:

Intent intent = new Intent(Control.Intents.CONTROL_SEND_LAYOUT_INTENT);
intent.putExtra(Control.Intents.EXTRA_LAYOUT_REFERENCE, layoutReference);
intent.putExtra(Control.Intents.EXTRA_PADDING_LEFT, paddingLeft);
controlExtension.sendToHostApp(intent);

I am well aware, that there is neither CONTROL_SEND_LAYOUT_INTENT nor EXTRA_PADDING_LEFT in the Control.Intents, as well as of the fact, that something similar can be done with the CONTROL_PROCESS_LAYOUT_INTENT, but there is a note in the documentation:

Note that the extension must always send a layout covering the full screen according to the display screen size. This means that even though the extension wants to update a portion of the screen a full screen layout must be supplied anyway.

So in my case I would need to create 220 equal xml-files with the only difference, that paddingLeft is set to 220, 219, 218, etc. and to set the right layout every time? It doesn't sound right for me :-)

Another workaround would be to use ImageView instead of the TextView and convert text to the Bitmap every time on the Host and to send the update through "setImage" to the Watch, in fact I have already implemented it this way, but it's not really a high-performance solution ...

I have also thought of sending the text with the spaces in front, like:

  1. "___Hello_world!"
  2. "__Hello_world!"
  3. "_Hello_world!"

but I would like to have a greater granularity of the movement.

So does anybody have any ideas about how to change the "paddingLeft"?

Oleg Skr
  • 386
  • 2
  • 9
  • If it is required that XML is passed to build a layout, you could always "alter" the XML dynamically in code. Of course it would probably not be a good approach if trying to do a marque or slide .. – user2864740 Oct 16 '13 at 09:44
  • As far as I see you can only send the R.layout.layoutID through the Control.Intents.EXTRA_DATA_XML_LAYOUT. Could you tell me please, how to change the xml? – Oleg Skr Oct 16 '13 at 09:48
  • I could do: `LayoutInflater inflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(layoutID, null); ControlViewGroup mLayout = (ControlViewGroup) parseLayout(layout); ControlView scrollingText = mLayout.findViewById(R.id.scrollingText);` but there is no "altering" functions in the `com.sonyericsson.extras.liveware.extension.util.control.ControlView` – Oleg Skr Oct 16 '13 at 09:56
  • Sorry, I thought you could use the code I posted in the onstart/onresume of a controlextension but I must have miss understood the sdk. – Matt Oct 16 '13 at 12:32
  • Oleg, you write: "Note that the extension must always send a layout covering the full screen according to the display screen size. This means that even though the extension wants to update a portion of the screen a full screen layout must be supplied anyway." That is not 100% correct, I'll give you more details on the other question you posed here: http://stackoverflow.com/questions/19402631/sony-smartwatch-update-text-in-multiple-textviews-simultaneously/19426303 – Eir Oct 24 '13 at 17:11

1 Answers1

0

That is quite some strange way to implement what is known as Animation, and for which there is already an example in the documentation of the Sony SmartWatch SDK.

ADDITIONAL EDITING: You cannot achieve smooth animation on the SmartWatch, because you don't control the screen, you just periodically send the data to be displayed on the screen, and you send it via the intent. So it's clear why you cannot achieve any smoothness, the "refresh rate" is just too low.

Again: the best animation you can get is what you will find implemented in the documentation, see the SimpleControl app, that's the first thing anyone should see in that documentation.

Eir
  • 1,003
  • 9
  • 24
  • Is this an answer? :-) In the example - the images are combined into the Animation. What I need - is to "move" the text to 1px each 100ms. I could do that through drawing text with offset on canvas of the Bitmap, that would be sent over Bluetooth from host to the watch, but performance is pretty bad in this case. The motion of the text looks laggy and not smooth at all. – Oleg Skr Oct 24 '13 at 11:33
  • Да, and I'll tell you why it is an answer: 1) It makes clear to you that what you are trying to achieve is called Animation, and points out where to find an example implementation. 2) It sets you off the wrong path you're trying to follow. Have you ever made animations in the way you are proposing, by gradually modifying the layout properties? I don't think so, and even if you did, there is no chance that you have accomplished a smooth animation. I'll supplement my answer with the rest I want to say. – Eir Oct 24 '13 at 17:01
  • Thank you for your interest in my question! An example of modifying the layout properties comes from the early HTML-practice, like [here](http://jsfiddle.net/x4Cfd/) – Oleg Skr Oct 25 '13 at 08:50