2016-10-03 8 views
0

私のアプリではListFragmentFloatingActionButtonがあります。ここでListFragment FloatingActionButtonが間違った位置にある

ListFragmentのレイアウトです:Androidのメーカーで

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/main_content" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <include layout="@android:layout/list_content"/> 

    <ListView 
     android:id="@id/android:list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <TextView 
     android:id="@id/android:empty" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:text="@string/no_contacts"/> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="16dp" 
     android:src="@drawable/ic_add" 
     app:layout_anchor="@id/android:list" 
     app:layout_anchorGravity="bottom|end" 
     android:layout_alignParentEnd="true"/> 
</android.support.design.widget.CoordinatorLayout> 

FABはbottom-right位置にあるが、私はそれはtop-left ATのアプリを実行したとき。

答えて

0

は、あなたが含まれたタグを使用して、このレイアウトに追加するレイアウトのListViewコントロールとのTextViewを追加し、この

<android.support.design.widget.FloatingActionButton 
android:id="@+id/fab" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="bottom|end" 
android:layout_margin="16dp" 
android:src="@drawable/ic_add" 
app:layout_anchor="@id/android:list" 
app:layout_anchorGravity="bottom|end" 
android:layout_alignParentBottom="true" 
android:layout_alignParentRight="true" 
/> 

0

を使用してみてください。

0

私の作業用レイアウトです。

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <include layout="@android:layout/list_content" /> 

    <ListView 
     android:id="@id/android:list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <TextView 
     android:id="@id/android:empty" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:text="no contacts" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="16dp" 
     android:src="@android:drawable/ic_input_add" 
     app:layout_anchor="@id/android:list" 
     app:layout_anchorGravity="bottom|end" /> 
</android.support.design.widget.CoordinatorLayout> 

そして、デバイスのレイアウトをかなり上手く示しています。私のアプリListFragmentで

enter image description here

+0

はViewPager(タブ)であり、これは私が得るものです:少しを検索して、[リンク](http://i.imgur.com/F4hskOe.png) –

+0

ファクトがメインのアクティビティレイアウトに配置されている必要があると判明した場合(マテリアルデザインのガイドライン[こちら](https://material.google.com/components/buttons-floating-action-button.html#buttons-floatingに従って) -action-button-behavior)とそれを行う方法[ここ](http://stackoverflow.com/questions/31596640/fab-animation-with-viewpager-tabslider/31663686#31663686) –

関連する問題