Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here you go, sir :</p> <pre><code>MainActivity : public class MainActivity extends Activity { private View animatedView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); animatedView = findViewById(R.id.view); } public void animate(View view) { int targetX = ((View) animatedView.getParent()).getWidth() - animatedView.getWidth() / 2; ObjectAnimator.ofFloat(animatedView, "x", 0, targetX).setDuration(1000).start(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } </code></pre> <p>Layout XML :</p> <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"&gt; &lt;TextView android:id="@+id/view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#CC0000" android:padding="30dp" android:textColor="@android:color/white" android:text="@string/hello_world"/&gt; &lt;Button style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Animate" android:onClick="animate" android:id="@+id/button" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true"/&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload