android-工具栏扩展了屏幕大小

时间:2016-06-02 14:24:00

标签: android

在我的应用程序中,我有一个活动,其中3个选项卡通过视图寻呼机和标签布局实现,其中一个是聊天片段。 问题是,在这个片段布局的底部,我有EditText和发送按钮,它们隐藏在屏幕边框下,当我向下滚动嵌套滚动时,它可以在图像中看到:

EditText and send button hidden

EditText and send button apear

活动布局.xml:



<android.support.design.widget.CoordinatorLayout
    android:id="@+id/activity_event_details"
    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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".eventdetails.EventDetailsActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:fitsSystemWindows="true"

        android:layout_height="wrap_content">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"

            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:background="?attr/colorPrimary"
            android:elevation="6dp"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_scrollFlags="scroll|enterAlways">
            <ImageButton
                android:fitsSystemWindows="true"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="right"
                android:src="@drawable/ic_launcher"
                android:id="@+id/event_creator_button"
                android:background="#00000000"
                android:nestedScrollingEnabled="true" />
        </android.support.v7.widget.Toolbar>
        <android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:background="?attr/colorPrimary"
            android:elevation="6dp"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>




    </android.support.design.widget.AppBarLayout>
    <!--<LinearLayout-->
        <!--android:layout_width="match_parent"-->
        <!--android:layout_height="match_parent"-->
        <!--android:orientation="vertical"-->
        <!--app:layout_behavior="@string/appbar_scrolling_view_behavior">-->

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"

            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/tab_layout"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


</android.support.design.widget.CoordinatorLayout>
&#13;
&#13;
&#13;

片段布局(我不认为问题在这里,但无论如何......):

&#13;
&#13;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".eventdetails.EventChatFragment">

    <ListView
        android:id="@+id/messageListView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/linearLayout"/>

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/messageEditText"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"/>

        <Button
            android:id="@+id/sendButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:enabled="false"
            android:text="SEND"/>

    </LinearLayout>




</RelativeLayout>
&#13;
&#13;
&#13;

我无法弄清楚应用程序的原因是什么&#34;扩展&#34;屏幕,以及如何解决它。试图搜索很多,但没有任何帮助.. 非常感谢!

1 个答案:

答案 0 :(得分:0)

我假设您通过android studio向导选择了例如,创建了这个活动布局。基本布局?打开可视化编辑器,您将看到带有height=match_parent的LinearLayout将具有隐藏的底部部分。对我来说,我将android.support.design.widget.CoordinatorLayout更改为RelativeLayout,并使用它将内容放在工具栏下面。

观看蓝色边框:http://postimg.org/image/dz1x2y6gb/

http://postimg.org/image/xse0vnju3/

当我注意到我的ListView的最后一项没有显示时,我也遇到了这个问题。

修改

试试这个:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/activity_event_details"
    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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".eventdetails.EventDetailsActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:fitsSystemWindows="true"

        android:layout_height="wrap_content">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"

            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:background="?attr/colorPrimary"
            android:elevation="6dp"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_scrollFlags="scroll|enterAlways">
            <ImageButton
                android:fitsSystemWindows="true"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="right"
                android:src="@drawable/ic_launcher"
                android:id="@+id/event_creator_button"
                android:background="#00000000"
                android:nestedScrollingEnabled="true" />
        </android.support.v7.widget.Toolbar>
        <android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:background="?attr/colorPrimary"
            android:elevation="6dp"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>




    </android.support.design.widget.AppBarLayout>
    <!--<LinearLayout-->
    <!--android:layout_width="match_parent"-->
    <!--android:layout_height="match_parent"-->
    <!--android:orientation="vertical"-->
    <!--app:layout_behavior="@string/appbar_scrolling_view_behavior">-->

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/appBarLayout"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


</RelativeLayout>