Reputation: 374
Yes, I agree that these questions lack research effort but I could not think of a specific "keyword search" so I am posting the questions here
I want to draw one view on top of another.. The below view will be the canvas view which draws animations (for the main menu of my game) and the front view has buttons..
So.. Let me split my questions.. 1) How to get the above mentioned behavior?
2) How to change button texture (like when button is up and button is down)
3) How to do animation? (like button sliding from left to center when user opens the game)
Just tell me the things keywords I need to search to get the answers for each of the questions and I will be satisfied. Thanx in advance
Upvotes: 1
Views: 5617
Reputation: 1479
To answer the question - or question 1) - You can also place views on top of each other with FrameLayout
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<Button
android:layout_width="@dimen/score_red_size_width"
android:layout_height="@dimen/score_red_size_height"
android:id="@+id/time"
android:background="@drawable/time"
android:layout_gravity="center_horizontal"
android:textColor="@color/white"
android:textSize="@dimen/time_formatting"
android:layout_marginTop="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/time_text"
android:layout_gravity="center_horizontal|center_vertical"
android:textAlignment="center"
android:text="no time"
android:layout_marginBottom="@dimen/time_label_bottom_margin"
android:textColor="@color/white"
android:textSize="@dimen/time_formatting" />
</FrameLayout>
This will place some text over a button, with some additional layout/styling. Sometimes this is the simplest option!
Upvotes: 2
Reputation: 82543
1) How to get the above mentioned behavior?
By using a relative layout, you can position Views one on top of the other.
2) How to change button texture (like when button is up and button is down)
Android has different states describing the touch progress of a view. By declaring a State List, you can specify how the button looks during a particular state.
3) How to do animation? (like button sliding from left to center when user opens the game)
Here's a nice animation tutorial. You're probably looking for a Translate Animation.
Upvotes: 4