2017-06-28 35 views
0

因此,我在TabbedActivity中有這個fragment_list.xml。它有一個ListView和一個FloatingActionButton。但我不知道爲什麼,這個片段有點裁剪,所以ListView不能向下滾動直到底部,而FAB只顯示一點點。TabbedActivity中的片段被裁剪

下面是它的圖片。它是滾動的底部:

Image

fragment_list.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    tools:context="com.garudamaya.dennydap.lookingood.BlankFragment"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
      <ProgressBar 
       android:id="@+id/listProgress" 
       android:layout_width="64dp" 
       android:layout_height="64dp" 
       android:layout_centerVertical="true" 
       android:layout_centerHorizontal="true"/> 
      <ListView 
       android:id="@+id/listView" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:divider="@null" 
       android:dividerHeight="0dp"> 
      </ListView> 
    </RelativeLayout> 
    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|right|end" 
     android:layout_margin="@dimen/fab_margin" 
     android:background="@color/colorPrimaryDark" 
     app:srcCompat="@drawable/ic_sort_by_alpha_white_24px" 
     app:rippleColor="#FFF"/> 
</FrameLayout> 

fragment_tabbed.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    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="com.garudamaya.dennydap.lookingood.MainActivity$PlaceholderFragment"> 

    <TextView 
     android:id="@+id/section_label" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</RelativeLayout> 

activity_tabbed.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 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/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.garudamaya.dennydap.lookingood.MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="@dimen/appbar_padding_top" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:popupTheme="@style/AppTheme.PopupOverlay"> 

     </android.support.v7.widget.Toolbar> 

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

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

    <android.support.v4.view.ViewPager 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

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

任何想法?

+0

發佈您的TabbedActivity佈局xml代碼 –

+0

編輯主帖子。你走了。 @배준모 –

回答

0

試試這個,

<?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:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 


    <ProgressBar 
     android:id="@+id/listProgress" 
     android:layout_width="64dp" 
     android:layout_height="64dp" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:visibility="gone" /> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/mRecyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:dividerHeight="0dp" /> 

    <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_gravity="bottom|right|end" 
     android:layout_marginBottom="60dp" 
     android:layout_marginRight="8dp" 
     android:background="@color/colorPrimaryDark" 
     app:rippleColor="#FFF" 
     app:srcCompat="@drawable/ic_home_blue" /> 
</RelativeLayout> 
+0

我不使用RecyclerView –

+0

用Listview替換它爲我工作 –

+0

@DennyPradipta你試過 –

0

答案是: - 解決不同的佈局和waeight和使用,以求解這個問題

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:weightSum="2"> 

    <ListView 
     android:id="@+id/listView" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1.6" 
     android:divider="@null" 
     android:dividerHeight="0dp"></ListView> 


    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.4"> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:layout_gravity="bottom|right" 
      android:background="@color/colorPrimaryDark" 
      app:rippleColor="#FFF" 
      app:srcCompat="@drawable/ic_sort_by_alpha_white_24px" /> 
    </RelativeLayout> 
</LinearLayout> 

我跳這個佈局是完美的解決了這個probolem

+0

TabbedActivity。它有一個ListView和一個FloatingActionButton。 –

+0

浮動動作欄仍然裁剪。 –