如何在android中添加Footer内部线性布局
这是我的xml,我必须添加页脚,但我无法在下面添加页脚,我正在显示屏幕 欲望屏幕在下面 当前屏幕: 请告诉我如何添加页脚,我试过了,但它没有到底部,我已经应用了android Alined的底部属性不工作如何在android中添加Footer内部线性布局,android,Android,这是我的xml,我必须添加页脚,但我无法在下面添加页脚,我正在显示屏幕 欲望屏幕在下面 当前屏幕: 请告诉我如何添加页脚,我试过了,但它没有到底部,我已经应用了android Alined的底部属性不工作 此外,我还必须根据愿望屏幕将图像视图文本视图设置为高位。请帮助。您可以使用带有两个孩子的RelativeLayout。第一个是使用android:layout\u alignParentTop=“true”的线性布局,第二个是带有属性的页脚视图android:layout\u alignPa
此外,我还必须根据愿望屏幕将图像视图文本视图设置为高位。请帮助。您可以使用带有两个孩子的RelativeLayout。第一个是使用android:layout\u alignParentTop=“true”的线性布局,第二个是带有属性的页脚视图
android:layout\u alignParentBottom=“true”
创建其他布局fotter.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity" >
<looputill.RoundedImageView
android:id="@+id/login_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loop" />
<EditText
android:id="@+id/login_editUsername"
android:layout_width="226dp"
android:layout_height="45dp"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/top_rounded_white"
android:drawableLeft="@drawable/user_s_icon"
android:drawablePadding="@dimen/margin_10dp"
android:ems="10"
android:gravity="center"
android:hint="Username"
android:padding="@dimen/margin_10dp"
android:textColor="#0060a4"
android:textSize="@dimen/font_18dp" />
<Button
android:id="@+id/signin"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/rounded_blue"
android:padding="@dimen/margin_10dp"
android:text="Sign-In"
android:textColor="#ffffff"
android:textSize="@dimen/font_20dp" />
</LinearLayout>
然后在主布局的末尾包含此布局,如
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Your Text"/>
</LinearLayout>
试试这个:
<include layout="@layout/fotter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
将页脚小部件放在自己的布局中,并为布局赋予以下属性
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity" >
<looputill.RoundedImageView
android:id="@+id/login_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loop" />
<EditText
android:id="@+id/login_editUsername"
android:layout_width="226dp"
android:layout_height="45dp"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/top_rounded_white"
android:drawableLeft="@drawable/user_s_icon"
android:drawablePadding="@dimen/margin_10dp"
android:ems="10"
android:gravity="center"
android:hint="Username"
android:padding="@dimen/margin_10dp"
android:textColor="#0060a4"
android:textSize="@dimen/font_18dp" />
<Button
android:id="@+id/signin"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/rounded_blue"
android:padding="@dimen/margin_10dp"
android:text="Sign-In"
android:textColor="#ffffff"
android:textSize="@dimen/font_20dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/footer_layout"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
android:gravity="center|bottom"
然后为您的TextView或页脚中的任何小部件提供以下属性
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity" >
<looputill.RoundedImageView
android:id="@+id/login_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loop" />
<EditText
android:id="@+id/login_editUsername"
android:layout_width="226dp"
android:layout_height="45dp"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/top_rounded_white"
android:drawableLeft="@drawable/user_s_icon"
android:drawablePadding="@dimen/margin_10dp"
android:ems="10"
android:gravity="center"
android:hint="Username"
android:padding="@dimen/margin_10dp"
android:textColor="#0060a4"
android:textSize="@dimen/font_18dp" />
<Button
android:id="@+id/signin"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/rounded_blue"
android:padding="@dimen/margin_10dp"
android:text="Sign-In"
android:textColor="#ffffff"
android:textSize="@dimen/font_20dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/footer_layout"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
android:gravity="center|bottom"
试着这样,
android:layout_gravity="bottom"
您可以使用
RelativeLayout
实现这一点。在包含分隔符和TextView的底部保留LinearLayout,或者创建单独的footer.xml并将其包含在xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<looputill.RoundedImageView
android:id="@+id/login_imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loop" />
<EditText
android:id="@+id/login_editUsername"
android:layout_width="226dp"
android:layout_height="45dp"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/top_rounded_white"
android:drawableLeft="@drawable/user_s_icon"
android:drawablePadding="@dimen/margin_10dp"
android:ems="10"
android:gravity="center"
android:hint="Username"
android:padding="@dimen/margin_10dp"
android:textColor="#0060a4"
android:textSize="@dimen/font_18dp" />
<Button
android:id="@+id/signin"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_10dp"
android:background="@drawable/rounded_blue"
android:padding="@dimen/margin_10dp"
android:text="Sign-In"
android:textColor="#ffffff"
android:textSize="@dimen/font_20dp" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="copyright"
android:textSize="12sp" />
</LinearLayout>
您可以使用布局重量将线性布局分为两部分,第一部分重量应为95%,第二部分重量应为5%,保持方向与主要线性布局垂直。
您可以实现您的结果尝试在运行时添加页脚吗?但是存在错误,给定xml线性布局和相对布局顶部上部仍然出现错误这是正确的,但我希望将位设置为顶部所有您可以看到的东西顶部和图像视图之间的间隙较小,这是由于重心。使用边距@边