FloatActionButton異常な位置にアンドロイド関連のソリューション

最近の研究アンドロイドでは、以前にFAB美しいインターフェイスを確保するために、ListViewコントロールのインターフェイスで追加、ListViewコントロールはプルダウンリフレッシュ機能を持ってできるようにしたいの後ろに、私はGoogleの独自のコントロールを使用するつもりですSwipeRefreshLayoutリフレッシュを完了させます。

  • 変更activity_main.xml前

<?XMLバージョン= "1.0"エンコード= "UTF-8" ?> 
< アンドロイド.support.constraint.ConstraintLayoutのxmlns:アンドロイド= "http://schemas.android.com/apk/res/android" 
    のxmlns:アプリ= "HTTP ://schemas.android.com/apk/res-auto」
    のxmlns:ツール= "http://schemas.android.com/tools" 
    のandroid:layout_width = "match_parent" 
    のandroid:layout_height = "match_parent" > 

    < ListViewの
         アンドロイド:ID = "@ + ID / lvwStudent" 
        アンドロイド:layout_width = "match_parent" 
        のandroid:layout_height = "0dp"
        ツール:layout_editor_absoluteX = "8DP" 
        ツール:layout_editor_absoluteY = "8DP"  /> 

    < アンドロイド.support.design.widget.FloatingActionButton 
        アンドロイド:ID = "@ + ID / floatingActionButton" 
        アンドロイド:layout_width = "wrap_content" 
        のandroid:layout_height = "wrap_content " 
        アンドロイド:layout_marginBottom =" 4DP」
        アンドロイド:layout_marginStart = "8DP" 
        アンドロイド:クリッカブル= "true"の
        アンドロイド:フォーカス可能= "true"の
        アプリ:fabSize = "ノーマル" 
        のアプリ:layout_anchorGravity = "終わり|センター"
        アプリ:layout_constraintBottom_toBottomOf = "親" 
        アプリ:layout_constraintEnd_toEndOf = "親" 
        アプリ:layout_constraintStart_toStartOf = "親" 
        アプリ:srcCompat = "@描画可能な追加/"  /> 

</ android.support.constraint.ConstraintLayout >

 

 ドロップダウンリフレッシュ要求を実現するために、私は意志android.support.constraint.ConstraintLayoutの変更android.support.v4.widget.SwipeRefreshLayout
変更の発見FABが去った後、困惑。

私はそれがアンカーとFABの関係で提供されるべきであると思いますが、成功していない変更する方法。

別のXMLレイアウトファイルにListViewコントロールとリフレッシュ機能、そしてオーバーの参照が含まれます:トリッキーな方法を考えます。

  • student_list.xml

<?XMLバージョン= "1.0"エンコード= "UTF-8" ?> 
< android.support.v4.widget.SwipeRefreshLayout のxmlns:アンドロイド= "http://schemas.android.com/apk/res/android" 
    のandroid:layout_width = "match_parent" 
    アンドロイド:layout_height = "match_parent" 
    アンドロイド:ID = "@ + ID / swip_main_layout" 
    のxmlns:ツール= "http://schemas.android.com/tools" > 

    < ListViewコントロール
         のandroid:ID = "@ + ID / lvwStudent」
        アンドロイド:layout_width = "match_parent" 
        のandroid:layout_height = "0dp" 
        ツール:
        ツール:layout_editor_absoluteX = "8DP" 
        ツール:layout_editor_absoluteY = "8DP"  /> 

</ android.support.v4.widget.SwipeRefreshLayout > 
  • activity_main.xml

<?XMLバージョン= "1.0"エンコード= "UTF-8" ?> 
< android.support.constraint.ConstraintLayout のxmlns:アンドロイド= "http://schemas.android.com/apk/res/android" 
    のxmlns:アプリ= "HTTP ://schemas.android.com/apk/res-auto」
    のxmlns:ツール= "http://schemas.android.com/tools" 
    のandroid:layout_width = "match_parent" 
    のandroid:layout_height = "match_parent" > 

    < 含ま
         アンドロイド:layout_height = "match_parent" 
        のandroid:layout_width = "match_parent" 
        レイアウト= "@レイアウト/ student_list"

    android.support.design.widget.FloatingActionButton
         アンドロイド:ID = "@ + ID / floatingActionButton" 
        アンドロイド:layout_width = "wrap_content" 
        のandroid:layout_height = "wrap_content" 
        アンドロイド:layout_marginBottom = "4DP" 
        アンドロイド:layout_marginStart = "8DP" 
        アンドロイド:クリッカブル= "true"の
        アンドロイド:フォーカス可能= "true"の
        アプリ:fabSize = "ノーマル" 
        アプリ:layout_anchorGravity = "終わり|センター" 
        アプリ:layout_constraintBottom_toBottomOf = "親" 
        アプリ:layout_constraintEnd_toEndOf = "親"
        アプリ:layout_constraintStart_toStartOf = "親" 
        アプリ:srcCompat = "@描画可能な追加/"  /> 

</ android.support.constraint.ConstraintLayout >

 

そして、あなたに実機を表示

 

 問題解決

 / ************************************************* ************************************************ /

その後の発見学習プロセスでは、SwipeRefreshLayoutは、この使用を好むかもしれない、効果が到達することができます

     < android.support.v4.widget.SwipeRefreshLayout
             アンドロイド:ID = "@ + ID / swip_main_layout" 
            アンドロイド:layout_width = "match_parent" 
            アンドロイド:layout_height = "match_parent" > 

            < リストビュー
                 アンドロイド:ID = "@ + ID / lvwStudent" 
                アンドロイド:layout_width = "match_parent" 
                アンドロイド:layout_height = "0dp"  /> 

     </ android.support.v4.widget.SwipeRefreshLayout > 

    < android.support.design.widget.FloatingActionButton
         アンドロイド:ID =」@ + ID / floatingActionButton」 
        アンドロイド:layout_width= "wrap_content" 
        のandroid:layout_height = "wrap_content" 
        アンドロイド:layout_marginBottom = "4DP" 
        アンドロイド:layout_marginStart = "8DP" 
        アンドロイド:クリッカブル= "true"の
        アンドロイド:フォーカス可能= "true"の
        アプリ:fabSize = "ノーマル" 
        アプリ:layout_anchorGravity = "終わり|センター" 
        アプリ:layout_constraintBottom_toBottomOf = "親" 
        アプリ:layout_constraintEnd_toEndOf = "親" 
        アプリ:layout_constraintStart_toStartOf = "親" 
        アプリ:srcCompat =」@描画可能/」を追加 />

 

おすすめ

転載: www.cnblogs.com/sds2xy/p/12510815.html