2011-09-26 90 views
1

的底部稍上方的位置我需要在屏幕底部放置一个按钮,在它下面留下一些空间。 换句话说,我使用这两个属性为我的按钮 -如何将一个按钮放在android

android:layout_alignParentBottom="true" 
android:layout_marginBottom="20dp" 

但幅度不会属性工作时,我使用alignParentBottom和按钮枝只在底部。请告诉我如何将它放在底部以上一点。

这里的XML

<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:gravity="center_horizontal" 
android:background="@drawable/board" 
android:layout_marginLeft="10dp" 
android:layout_marginRight="60dp" 
android:layout_marginTop="15dp" 
android:layout_marginBottom="10dp"> 


     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center_horizontal" 
      android:text="Type of Lesion" 
      android:textColor="#8B0A50" 
      android:layout_marginTop="40dp" 
      android:id="@+id/disease_listheader_textview" 
      android:drawableBottom="@drawable/underline"/> 

     <ListView 
      android:id="@+id/disease_listview" 
      android:layout_below="@id/disease_listheader_textview" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:divider="@drawable/divider" 
      android:layout_marginLeft="40dp" 
      android:layout_marginBottom="50dp" 
      android:cacheColorHint="#00000000"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/disease_search_button" 
      android:layout_centerHorizontal="true" 
      android:background="@drawable/disease_search_btn" 
      android:layout_alignParentBottom="true" 
      android:layout_marginBottom="20dp"/> 

    </RelativeLayout> 
+0

能你把你的布局xml在这里? –

+0

显示完整的按钮xml与外部布局.. – Ronnie

+0

@RahulChoudhary我已经把xml – Ankit

回答

0

这仅仅运行你想

<RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="fill_parent"> 
    <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="20dip"></Button> 
</RelativeLayout> 
+0

NOE没有为我工作 – Ankit

+0

哈哈,以及发布整个布局找到你的bug,我发布的代码绝对有效我尝试在我自己的电脑 – Lukap

+0

而不是android:layout_height =“wrap_content”put fill_parent – Lukap

1

你可以试试这个方式?

  1. 将Button标签替换为下面提到的标签。我试图总结在另一个虚拟布局按钮

    <LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    android:paddingBottom="20dp"> 
    
    <Button 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:id="@+id/disease_search_button" 
         android:background="@drawable/disease_search_btn" 
         android:layout_marginBottom="20dp"/> 
    
    </LinearLayout> 
    
3

只是使相对布局高度改变属性值fillparent像

<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
    .................../> 


希望这有助于你

相关问题