首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

多行EditText下方的按钮对齐方式

可以通过布局属性来实现。常见的对齐方式有居中对齐、靠左对齐和靠右对齐。

  1. 居中对齐:可以使用LinearLayout布局,并设置gravity属性为center_horizontal。示例代码如下:
代码语言:xml
复制
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_horizontal">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine"
        android:gravity="top"
        android:minLines="3"
        android:maxLines="5"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮"/>

</LinearLayout>
  1. 靠左对齐:可以使用RelativeLayout布局,并设置按钮的对齐属性为alignParentBottom和alignParentLeft。示例代码如下:
代码语言:xml
复制
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine"
        android:gravity="top"
        android:minLines="3"
        android:maxLines="5"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"/>

</RelativeLayout>
  1. 靠右对齐:可以使用RelativeLayout布局,并设置按钮的对齐属性为alignParentBottom和alignParentRight。示例代码如下:
代码语言:xml
复制
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textMultiLine"
        android:gravity="top"
        android:minLines="3"
        android:maxLines="5"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"/>

</RelativeLayout>

以上是三种常见的多行EditText下方按钮对齐方式的示例代码。根据实际需求选择合适的布局方式和对齐属性即可。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

Android开发笔记(三十五)页面布局视图

布局视图有五类,分别是线性布局LinearLayout、相对布局RelativeLayout、框架布局FrameLayout、绝对布局AbsoluteLayout、表格布局TableLayout。其中最常用的是LinearLayout,它适用于包括简单布局在内的多数情况;其次常用的是RelativeLayout,它适用于一些复杂布局,主要是对相对位置要求较多的情况;再次就是FrameLayout,它一般用于需要叠加展示的场合,比如说给整个页面设置一个背景布局等等。AbsoluteLayout和TableLayout实际中很少用,基本不用关心。 另外还有纵向滚动视图ScrollView,以及横向滚动视图HorizontalScrollView,其作用顾名思义便是让它们的子视图可以在某个方向上滚动罢了。

03

Android实现滑动刻度尺效果,选择身高体重和生日

刻度尺效果虽然看起来很美,我个人认为很不实用,即使再不实用,也有用的,鉴于群里成员对我的苦苦哀求,我就分享一个他用不到的,横屏滑动刻度尺,因为他需要竖屏的,哈哈…… 最近群里的开发人员咨询怎样实现刻度尺的滑动效果去选择身高体重等信息。我倒是做过这种效果,貌似群里要的那个开发者要竖着的刻度尺,那我就先分享个横着的刻度尺滑动选择效果。哈哈……我就是这么贱,贱贱的才惹人爱嘛!好了,不逗了,先给个横着的效果,自己试着去改编或者修改一下,看看通过自己的能力能不能做出竖着的效果来,过两天我再把竖着的那个滑动选择效果分享

010
领券