是否有一个XML代码可以让我总是在我用java创建的按钮上面放置我的XML按钮?因为现在它只会在我的java按钮被禁用时显示我的XML按钮。
XML按钮:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_student_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="blah.Blah">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
app:fabSize="normal"
app:srcCompat="@android:drawable/ic_input_add"
android:id="@+id/floatingActionButton"
app:backgroundTint="?attr/colorBackgroundFloating"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
答案 0 :(得分:0)
android:id="@+id/floatingActionButton"
这是FloatingActionButton的ID,所以以这种方式声明它
FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.floatingActionButton);
fab.bringToFront();