AnnBnnCnnD 2012-12-19 07:17 采纳率: 0%
浏览 26860
已采纳

让LinearLayout的两个按钮之间有一些间隔

在LinearLayout中垂直布局两个按钮,想在两个按钮之间有一个间隔。不知道怎么实现,请帮忙。

布局文件如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:padding="10dp"
  >
<Button
    android:id="@+id/btnAction1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/cool_button"
    android:text = "HiText1"
/>

<Button
    android:id="@+id/btnAction2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/cool_button"
    android:text="HiText2"
    android:layout_below="@id/btnAction1"
/>        

</LinearLayout> 

图片:

CSDN移动问答

  • 写回答

1条回答 默认 最新

  • Kill_it 2012-12-19 07:28
    关注

    试试下面的代码:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
     android:padding="10dp"
     >
    <Button
       android:id="@+id/btnAction1"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:background="@drawable/cool_button"
       android:text = "HiText1"
    />
    
    <Button android:layout_marginTop="50dp"
       android:id="@+id/btnAction2"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:background="@drawable/cool_button"
       android:text="HiText2"
       android:layout_below="@id/btnAction1"
    />        
    
    </LinearLayout> 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面