0

How do i make my pause and play button overlay from one another? It just means that, when I press the button to pause the pause button will appear and when i press the button again the play button will appear.

<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"
android:background="#A9E2F3"
tools:context="${packageName}.${activityClass}" >



 <TextView
       android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:keepScreenOn="true"
        android:text="Audio Streaming"
        android:textSize="43sp" />   

    <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Play"
            android:id="@+id/button_play" android:layout_weight="1"
            android:drawableLeft="@android:drawable/ic_media_play"/>
    <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Pause"
            android:layout_alignTop="@id/button_play"
            android:layout_alignLeft="@id/button_play"
            android:id="@+id/button_pause" android:layout_weight="1"
            android:drawableLeft="@android:drawable/ic_media_pause"/>

             </RelativeLayout>

I dont even know if I've using the correct layout, isit relative, frame or linear? Thanks in advance!

1 Answers1

2

You can use only one button as toggle when you click it make flag true and set its text as play if flag is true then make it false and set its text as pause and so on...

as per flag write your code in if codition of flags

enjoy coding