2016-04-02 23 views
1

これは私のレイアウトファイルです。ボタンがアクティビティの下部に表示されない - android

<?xml version="1.0" encoding="utf-8"?> 

<android.support.v4.widget.DrawerLayout 
    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/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.design.widget.CoordinatorLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:id="@+id/coordinatorLayout" 
     android:orientation="vertical"> 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

      <include 
       android:id="@+id/toolbar" 
       layout="@layout/toolbar" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       app:layout_scrollFlags="scroll|enterAlways" 
       android:layout_alignParentTop="true"/> 


      <android.support.design.widget.TabLayout 
       android:id="@+id/tab_layout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/toolbar" 
       android:background="@color/primary" 
       android:elevation="6dp" 
       android:minHeight="?attr/actionBarSize" 
       app:tabIndicatorColor="@android:color/white" 
       app:tabIndicatorHeight="4dp" 
       android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/> 

     </android.support.design.widget.AppBarLayout> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/pager" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/tab_layout" 
      android:layout_above="@+id/floating_button" 
      android:background="@color/windowBackground" 
      android:paddingLeft="30dp" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

     <Button android:id="@+id/floating_button" 
      android:layout_width="match_parent" 
      android:layout_alignParentBottom="true" 
      android:layout_height="wrap_content" 
      android:text="Go to Shopping Cart" 
      android:theme="@style/MyButton"/> 


    </android.support.design.widget.CoordinatorLayout> 

    <fragment 
     android:id="@+id/fragment_navigation_drawer" 
     android:name="com.wokoshop.sony.fragment.FragmentDrawer" 
     android:layout_width="@dimen/nav_drawer_width" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:layout="@layout/fragment_navigation_drawer" 
     tools:layout="@layout/fragment_navigation_drawer" /> 

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

私はアクティビティのボタンの下部を表示しようとしています。しかし、それは全く表示されていません。

誰かが私に欠けているものを手伝ってもらえますか?

+0

はこれを参照してください:あなたのレイアウトを読んでから、

は、私はあなたがこのような何かをしたいと思います。 https://guides.codepath.com/android/floating-action-buttons –

答えて

3

私はあなたの問題を引き起こすいくつかの小さな問題があると思います。

1)cooridnatorレイアウトを相対レイアウトとして使用しようとしているため、alignParentBottomボタンは効果がありません。

2)コーディネーターレイアウトの方向は、線形レイアウトプロパティであり、効果はありません。

3)コーディネーターのレイアウトやその中にあるものは、完全な親を使用しないため、すべてがwrap_parentのみです。

<android.support.design.widget.CoordinatorLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

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

      <android.support.design.widget.AppBarLayout 
       android:id="@+id/appBarlayout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <!-- Whatever views you want here, your tablayout etc--> 

      </android.support.design.widget.AppBarLayout> 

      <android.support.v4.view.ViewPager 
       android:layout_below="@+id/appBarlayout" 
       android:layout_above="@+id/button" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 

      </android.support.v4.view.ViewPager> 

      <Button 
       android:id="@+id/button" 
       android:text="Hey" 
       android:layout_alignParentBottom="true" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

     </RelativeLayout> 

    </android.support.design.widget.CoordinatorLayout> 
関連する問題