I have a TableRow with a TextView. Here is the xml for it.
<TableRow
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:layout_width="fill_parent"
android:background="#BF000000">
<TextView
android:id="@+id/topText"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="19sp"
android:background="#BF000000"
android:layout_gravity="center_horizontal"
android:text="@string/text_searchword"
android:layout_width="fill_parent">
</TextView>
</TableRow>
I want to make the table row invisible with fadeout effect on a button touch and vice versa. How can I do it?
Any
View(TableRowincluded) can have a fade animation attached to it, but you’ll need to be able to reference your view in code, so the row will need an id:Now you can reference the row itself in your Java code somewhere (like
onCreate()perhaps) asNotice I don’t cast it as a
TableRow. You could if you need to do other things with it, but for just setting visibility leaving it as a View is fine. Then just construct a button click method like this:Fade in and Fade out are standard animations defined in the Android package, you don’t need to create them yourself, just load them using
AnimationUtils.loadAnimation(). In this example, the clicking the same button just toggles between fade in and fade out depending on whether or not the View is already visible.Hope that Helps!