简体   繁体   English

如何使按钮底部对齐,按钮下方没有任何空间

[英]How to make the buttons align bottom without any space below the buttons

How to align the buttons bottom of the screen.In the layout i have header below scrollview which contains many textviews and edittext and last is the 2 buttons that i want to place it bottom without any space be 如何将屏幕底部的按钮对齐。在布局中,我在scrollview下面有标题,其中包含许多textviews和edittext,最后是我想将其放置在底部没有任何空间的2个按钮 see at the bottom as i am able to align it bottom but ther is a small space between buttton and the screentween layout and buttons... 看到底部,因为我能够使其底部对齐,但是按钮和屏幕之间的布局和按钮之间的距离很小。

以相反的方式进行操作...打开-相对布局* Button1-父底部为真* Button2-父底部为真,Button1的右侧,顶部对齐Button1,底部对齐Button1 *标题-父顶部为真*滚动视图-标题下方和上方Button1关闭-相对布局

You can use android:layout_martin="0dp" to set the margin to zero, but with some Views this isn't enough as the 9Patch being used for the View background has a margin in it as well. 您可以使用android:layout_martin="0dp"将页边距设置为零,但是对于某些Views,这是不够的,因为用于View背景的9Patch也具有页边距。 In that case you need to both set the margin to zero, and use a different background 9patch. 在这种情况下,您需要将边距都设置为零,并使用不同的背景9patch。

http://developer.android.com/guide/developing/tools/draw9patch.html http://developer.android.com/guide/developing/tools/draw9patch.html

make them in separate layout and and arrange at parent bottom 将它们放在单独的布局中,并安排在父级底部

<LinearLayout            
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"       
     android:layout_alignParentBottom="true">

     <Button
         android:id="@+id/save_content"
         android:layout_width="wrap_content"
         android:text="save"
         android:layout_marginRight="5dp"
         android:textColor="#ffffff"        
         android:textStyle="bold"           
         android:textAppearance="?android:attr/textAppearanceMedium" 
         android:layout_height="35dp"
         android:layout_weight="1"/>

     <Button
         android:id="@+id/cancel_content"
         android:layout_width="wrap_content"
         android:layout_height="35dp"      
         android:text="cancel"
         android:textColor="#ffffff"       
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:layout_marginLeft="5dp"
         android:textStyle="bold"
         android:layout_weight="1"/>
 </LinearLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM