xiaoyan_12 2013-04-03 09:14 采纳率: 25%
浏览 2365

ImageButton的顶部显示不像Button和EditText那样对齐

在 layout.xml 中设置:

<EditText android:id="@+id/body" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1"
            android:hint="Type to compose" />
        <ImageButton android:id="@+id/attach"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:src="@drawable/attach_photo" />
        <Button android:id="@+id/send" android:text="@string/send"
            android:layout_width="wrap_content" android:layout_height="wrap_content" />
    </LinearLayout>

现在遇到的问题是:ImageButton 的顶部显示不像 Button 和 EditText 那样。Button 和EditText 上的内容显示的时候,上下填充的很好。但是,ImageButton 上面的内容似乎向上突出了。如何设置按钮的显示呢?

  • 写回答

1条回答

  • Baby_Bonnie 2013-04-07 02:11
    关注

    使用一个 RelativeLayout。你可以把视图向两边对齐,父类的顶端和底部或者别的视图。
    使用android:layout_alignParentTop="true"
    在 RelativeLayout 中有大量的 xml 命令。

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable