2016-07-30 4 views
0

listViewの右下にフローティングインジケータを表示させるにはどうすればよいですか?listViewの右下にフローティングインジケータを表示させるにはどうすればよいですか?

何らかの理由で、以下のコードで浮動表示が表示されるか、またはlistViewの左上隅が表示されます。

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/main_layout" 
    android:fitsSystemWindows="true" 
    android:orientation="vertical"> 

    <include layout="@layout/toolbar_general"/> 

    <RelativeLayout android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

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

     <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="@dimen/fab_margin" 
      android:src="@android:drawable/ic_dialog_email" /> 

    </RelativeLayout> 

</LinearLayout> 
+0

使用alignParentRightとalignParentBottom – Nisarg

+0

利用アンドロイド:layout_alignParentBottom = "true" android:layout_alignParentRight = "true" –

答えて

1

を試してみてください:重力はビューではないビュー内のコンテンツの重力を設定し、自体。 代わりに...あなたは...望ましい結果を得るために、このような をalignParentBottomとalignParentRightプロパティを使用する必要があります...

<android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_margin="@dimen/fab_margin" android:src="@android:drawable/ic_dialog_email" />

希望このヘルプ...

1

問題は、あなたがfloatingActionButtonで使用重力プロパティ... アンドロイドであるこの

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/main_layout" 
android:fitsSystemWindows="true" 
android:orientation="vertical"> 

<include layout="@layout/toolbar_general"/> 

<RelativeLayout android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

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

    <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="@dimen/fab_margin" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_marginRight="10dp" 
     android:layout_marginBottom="10dp" 
     android:src="@android:drawable/ic_dialog_email" /> 

</RelativeLayout> 

関連する問題