如何叠加播放和暂停按钮?

时间:2014-07-23 09:49:02

标签: android android-layout

如何让我的暂停和播放按钮重叠?这只是意味着,当我按下按钮暂停时,将出现暂停按钮,当我再次按下按钮时,将出现播放按钮。

<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>

我甚至不知道我是否使用了正确的布局,isit relative,frame还是linear? 提前致谢!

1 个答案:

答案 0 :(得分:2)

如果标记为true,则只能使用一个按钮作为切换,如果flag为true,则将其文本设置为play,然后将其设为false并将其文本设置为暂停等等...

根据标志写入你的代码,如果标志的编码

享受编码