Guest User

Untitled

a guest
Apr 30th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.24 KB | None | 0 0
  1. Is it possible to center an image with an animation from an XML file?
  2. <?xml version="1.0" encoding="utf-8"?>
  3. <translate
  4. xmlns:android="http://schemas.android.com/apk/res/android"
  5. android:fromXDelta="0%"
  6. android:toXDelta="-50%p"
  7. android:fromYDelta="0%"
  8. android:toYDelta="50%p"
  9. android:duration="1000"
  10. android:fillEnabled="false"
  11. android:fillAfter="true">
  12. </translate>
  13.  
  14. <?xml version="1.0" encoding="utf-8"?>
  15. <LinearLayout
  16. xmlns:android="http://schemas.android.com/apk/res/android"
  17. android:id="@+id/board_layout"
  18. android:layout_width="fill_parent"
  19. android:layout_height="fill_parent"
  20. android:background="@drawable/background"
  21. android:orientation="vertical">
  22.  
  23. <LinearLayout
  24. android:layout_width="fill_parent"
  25. android:layout_height="fill_parent"
  26. android:layout_margin="100dp"
  27. android:orientation="vertical">
  28.  
  29. <ImageView
  30. android:id="@+id/cardsPileImage"
  31. android:layout_width="100dp"
  32. android:layout_height="wrap_content"
  33. android:src="@drawable/back"
  34. android:layout_gravity="right"
  35. android:layout_marginTop="10dp"
  36. android:layout_marginRight="10dp"
  37. android:adjustViewBounds="true">
  38. </ImageView>
  39.  
  40. <LinearLayout
  41. android:layout_width="wrap_content"
  42. android:layout_height="wrap_content"
  43. android:layout_weight="1"
  44. android:layout_gravity="center"
  45. android:gravity="center">
  46.  
  47. <Button
  48. android:layout_width="wrap_content"
  49. android:layout_height="wrap_content"
  50. android:background="@drawable/round_button"
  51. android:paddingLeft="60dp"
  52. android:paddingRight="60dp"
  53. android:textSize="25dp"
  54. android:text="@string/start_game"
  55. android:onClick="startGame">
  56. </Button>
  57.  
  58. </LinearLayout>
  59.  
  60. <ImageView
  61. android:id="@+id/discardPileImage"
  62. android:layout_width="100dp"
  63. android:layout_height="wrap_content"
  64. android:src="@drawable/back"
  65. android:layout_gravity="right"
  66. android:layout_marginTop="10dp"
  67. android:layout_marginRight="10dp"
  68. android:adjustViewBounds="true">
  69. </ImageView>
  70.  
  71. </LinearLayout>
  72.  
  73. </LinearLayout>
  74.  
  75. <?xml version="1.0" encoding="utf-8"?>
  76. <RelativeLayout
  77. xmlns:android="http://schemas.android.com/apk/res/android"
  78. android:id="@+id/board_layout"
  79. android:layout_width="fill_parent"
  80. android:layout_height="fill_parent"
  81. android:background="#FFFFFF"
  82. android:orientation="vertical">
  83.  
  84. <ImageView
  85. android:id="@+id/cardsPileImage"
  86. android:layout_width="100dp"
  87. android:layout_height="wrap_content"
  88. android:src="@drawable/icon"
  89. android:layout_gravity="right"
  90. android:layout_marginTop="110dp"
  91. android:layout_marginRight="10dp"
  92. android:layout_marginLeft="10dp">
  93. </ImageView>
  94.  
  95. <Button
  96. android:layout_below="@+id/cardsPileImage"
  97. android:layout_width="wrap_content"
  98. android:layout_height="wrap_content"
  99. android:background="@drawable/icon"
  100. android:id="@+id/backButton"
  101. android:paddingLeft="60dp"
  102. android:paddingRight="60dp"
  103. android:textSize="25dp"
  104. android:text="Start Game"
  105. android:onClick="startGame">
  106. </Button>
  107.  
  108. <ImageView
  109. android:id="@+id/discardPileImage"
  110. android:layout_below="@+id/backButton"
  111. android:layout_width="100dp"
  112. android:layout_height="wrap_content"
  113. android:src="@drawable/icon"
  114. android:layout_gravity="right"
  115. android:layout_marginTop="10dp"
  116. android:layout_marginRight="10dp"
  117. android:adjustViewBounds="true">
  118. </ImageView>
  119.  
  120. </RelativeLayout>
  121.  
  122. <?xml version="1.0" encoding="utf-8"?>
  123. <LinearLayout
  124. xmlns:android="http://schemas.android.com/apk/res/android"
  125. android:id="@+id/board_layout"
  126. android:layout_width="fill_parent"
  127. android:layout_height="fill_parent"
  128. android:background="#FFFFFF">
  129.  
  130. <RelativeLayout
  131. android:layout_height="fill_parent"
  132. android:layout_width="fill_parent"
  133. android:layout_margin="100dp"
  134. android:gravity="center"
  135. android:layout_gravity="center">
  136.  
  137. <ImageView
  138. android:id="@+id/cardsPileImage"
  139. android:layout_width="wrap_content"
  140. android:layout_height="wrap_content"
  141. android:src="@drawable/icon"
  142. android:layout_gravity="right"
  143. android:layout_alignParentRight="true"
  144. >
  145. </ImageView>
  146. <Button
  147. android:layout_below="@+id/cardsPileImage"
  148. android:layout_width="wrap_content"
  149. android:layout_height="wrap_content"
  150. android:background="@drawable/icon"
  151. android:id="@+id/backButton"
  152. android:layout_centerInParent="true"
  153. android:textSize="20dp"
  154. android:layout_margin="10dp"
  155. android:text="Start Game"
  156. android:onClick="startGame">
  157. </Button>
  158.  
  159. <ImageView
  160. android:id="@+id/discardPileImage"
  161. android:layout_below="@+id/backButton"
  162. android:layout_width="wrap_content"
  163. android:layout_height="wrap_content"
  164. android:src="@drawable/icon"
  165. android:layout_gravity="right"
  166. android:layout_alignParentRight="true"
  167. >
  168. </ImageView>
  169.  
  170. </RelativeLayout>
  171. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment