i want to make the buttons take up half the width of the dialog each, thanks x3. enter image description here

我想让按钮占据对话框宽度的一半,谢谢x3。

<RelativeLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:paddingBottom="10dp"
    android:paddingLeft="10dp" android:paddingRight="10dp">
    <TextView android:layout_width="fill_parent"
        android:layout_height="1dip" android:background="#FFFFFF" android:id="@+id/seperator_line" />
    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:id="@+id/text1"
        android:text="Amount:" android:textColor="#FFFFFF"
        android:layout_below="@id/seperator_line" android:padding="10dp" />
    <Button android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:id="@+id/deleteButton_dialog"
        android:layout_below="@id/text1" android:text="Delete" />
    <Button android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:id="@+id/cancelButton_dialog"
        android:text="Cancel" android:layout_toRightOf="@id/deleteButton_dialog"
        android:layout_below="@id/text1" />
</RelativeLayout>

1 个解决方案

#1


1

You can place them in a LinearLayout and then set the width to "fill_parent" and the layout_weight to "1". Like this:

您可以将它们放在LinearLayout中,然后将宽度设置为“fill_parent”,将layout_weight设置为“1”。喜欢这个:

<LinearLayout android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal"
              android:layout_below="@id/text1">
    <Button android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/deleteButton_dialog"
            android:text="Delete" />
    <Button android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:id="@+id/cancelButton_dialog"
            android:text="Cancel"/>
</LinearLayout>

更多相关文章

  1. 安卓,如何让两个按钮相邻,宽度相同
  2. Java多线程聊天对话框
  3. 基于内容估计文本宽度的算法
  4. jQuery(JavaScript)获取文字(字符串)宽度(显示长度)

随机推荐

  1. Android 4.0+ 版本中的EditText字符重叠
  2. Android面试系列文章2018之Android部分事
  3. Android(安卓)apk的安装、卸载
  4. Android中使用事件总线的优缺点
  5. Smack和Asmack
  6. Android开发都需要使用什么语言?
  7. Android imageView 实现小红点(动画呼吸效
  8. Android—TextView的XML属性和方法
  9. Android(安卓)学习资料大集合
  10. Fragment的添加方法总结