2013-03-18 67 views
0

我想在我的listview-fragment底部的确定/取消按钮接受/取消。我认为碎片是要走的路(甚至应该支持动画)。如何添加底部按钮片段(动画)

但我无法让它工作!只显示(在代码fragmentPlaceholder)的第一个片段

的按钮的XML已经我从这篇文章的接受的答案得到:

How to create standard Borderless buttons (like in the design guidline mentioned)?

的代码是C#,但问题应该在Java中也是一样。对于片段中的XML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="48dp" 
     android:layout_alignParentBottom="true"> 
     <View 
      android:layout_width="match_parent" 
      android:layout_height="1dip" 
      android:layout_marginLeft="4dip" 
      android:layout_marginRight="4dip" 
      android:background="?android:attr/dividerVertical" 
      android:layout_alignParentTop="true"/> 
     <View 
      android:id="@+id/ViewColorPickerHelper" 
      android:layout_width="1dip" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentBottom="true" 
      android:layout_marginBottom="4dip" 
      android:layout_marginTop="4dip" 
      android:background="?android:attr/dividerVertical" 
      android:layout_centerHorizontal="true"/> 
     <Button 
      android:id="@+id/btnCancel" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_toLeftOf="@id/ViewColorPickerHelper" 
      android:background="?android:attr/selectableItemBackground" 
      android:text="Cancel" 
      android:layout_alignParentBottom="true"/> 
     <Button 
      android:id="@+id/BtnColorPickerOk" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true" 
      android:background="?android:attr/selectableItemBackground" 
      android:text="Ok" 
      android:layout_alignParentBottom="true" 
      android:layout_toRightOf="@id/ViewColorPickerHelper"/> 
    </RelativeLayout> 

为活性的XML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:id="@+id/fragmentPlaceholder" /> 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/addEventReportButtonPlaceholder" 
      android:layout_weight="10" 
      android:layout_gravity="bottom" /> 
    </LinearLayout> 
    <ProgressBar 
     android:id="@+id/addEventReportProgressBar" 
     android:indeterminate="true" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     style="?android:attr/progressBarStyle" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true" /> 
</RelativeLayout> 

包括所述片段的代码:

var newFragment = new BottomButtonsFragment(); 
FragmentTransaction ft = FragmentManager.BeginTransaction(); 
ft.Add (Resource.Id.addEventReportButtonPlaceholder, newFragment).Commit(); 

哪里BottomButtonsFragment是:

public class BottomButtonsFragment : Fragment 
{ 
    public override View OnCreateView (LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) 
    { 
     View v = inflater.Inflate (Resource.Layout.BottomButtonsFragment, container, false); 
     return v; 
    } 
} 

回答

0

设置android:layout_最重要的LinearLayout的重量远远超过底部的重量,解决了问题!

相关问题