【发布时间】:2016-02-11 13:47:28
【问题描述】:
我是 android 新手,我只是想创建一个聊天客户端。然而,底部的内容只是离开屏幕。
布局文件:
chat_layout.xml
<RelativeLayout 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="#e1e1e1"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="#91f1f1f1"
android:orientation="horizontal"
android:paddingBottom="2dp" >
<ImageButton
android:id="@+id/sendMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@drawable/send_button"
android:text="d" />
</LinearLayout>
</RelativeLayout>
activity_mail.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.marothiatechs.mchat.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
这在 Android Studio 的预览窗口中看起来不错。
但是当我将线性布局的“paddingBottom”增加为“200dp”时,按钮变得可见。
我在 SO 上发现了类似的问题,其中大多数建议使用 ScrollView。但我认为 ScrollView 在我的情况下是不必要的。有什么想法吗?
【问题讨论】:
-
添加
android:layout_alignParentBottom="true" android:layout_gravity="bottom" -
你能发布布局文件的全部内容吗?因为你在那里的东西似乎工作正常
-
否决我的问题的人会解释原因吗?当我在我的设备上运行代码时,我遇到了一个真正的问题。在 Android Studio 上,它看起来不错。
-
@DalmaRacz - 这是完整的布局文件。我删除了 EditText 等以简化问题。
-
@IntelliJAmiya - 相对布局或线性布局
标签: android android-layout android-fragments