Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to center an image with an animation from an XML file?
    primarykey
    data
    text
    <p>I have no problem to do this with java code, but i'm wondering if it's possible to center an imageView thanks to an XML animation file. Indeed, my ImageView is in a linearlayout with a margin of 100dp, at the top right of the screen, so when I do this, the image is not centered but at 100dp from top and right centered :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="0%" android:toXDelta="-50%p" android:fromYDelta="0%" android:toYDelta="50%p" android:duration="1000" android:fillEnabled="false" android:fillAfter="true"&gt; &lt;/translate&gt; </code></pre> <p>EDIT: my imageView, "cardsPileImage" is in this layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/board_layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background" android:orientation="vertical"&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="100dp" android:orientation="vertical"&gt; &lt;ImageView android:id="@+id/cardsPileImage" android:layout_width="100dp" android:layout_height="wrap_content" android:src="@drawable/back" android:layout_gravity="right" android:layout_marginTop="10dp" android:layout_marginRight="10dp" android:adjustViewBounds="true"&gt; &lt;/ImageView&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:layout_gravity="center" android:gravity="center"&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/round_button" android:paddingLeft="60dp" android:paddingRight="60dp" android:textSize="25dp" android:text="@string/start_game" android:onClick="startGame"&gt; &lt;/Button&gt; &lt;/LinearLayout&gt; &lt;ImageView android:id="@+id/discardPileImage" android:layout_width="100dp" android:layout_height="wrap_content" android:src="@drawable/back" android:layout_gravity="right" android:layout_marginTop="10dp" android:layout_marginRight="10dp" android:adjustViewBounds="true"&gt; &lt;/ImageView&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>Thanks you per advance :-)</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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