2017-03-01 4 views
-1

Javaで作成したボタンの上に常にXMLボタンを表示できる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

view.bringToFront() –

+0

@EliasFazelでそれを宣言FloatingActionButtonのIDですXMLは前面にあり、XMLコードはありますか?私はbringToBack()関数が私のJavaボタンを背中に置くために使うのを見ていません。 –

+0

in findViewById()後 –

答えて

0
android:id="@+id/floatingActionButton" 

これは私が持参しようとしているこのよう

FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.floatingActionButton); 
fab.bringToFront(); 
+0

これを行うと、ボタンだけが表示されます。両方を表示させる方法はありますか?これは、私がjavaで作成したボタンを完全に無効にし、XMLボタンのみを画面に表示します。 –

+0

xmlのビューの位置を変更します –

+0

右下隅にあり、Javaボタンはそれほど遠くには行かないので、重なり合うことはありません。 –

関連する問題