0

我今天在我的应用程序中添加了一个滚动视图。我想要像谷歌现在卡这样的东西。它有效,但我希望它是全屏的,但在底部。在底部,我有一个 EditText 和一个 Button,我希望滚动视图停在那里,以便它们都可见。我怎样才能做到这一点?:s 那是我的活动:

 <android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/chat_layout"
                    android:icon="@drawable/ic_linkrholoorange"
                    xmlns:tools="http://schemas.android.com/tools"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:paddingLeft="@dimen/activity_horizontal_margin"
                    android:paddingRight="@dimen/activity_horizontal_margin"
                    android:paddingTop="@dimen/activity_vertical_margin"
                    android:paddingBottom="@dimen/activity_vertical_margin"
                    tools:context=".Chat"
                    android:text = "Now">


        <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
                    xmlns:tools="http://schemas.android.com/tools"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:fillViewport="true" >

        <com.linkr.chat.NowLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#e3e3e3"
                    android:orientation="vertical">
                <TextView
                        android:id="@+id/card"
                        style="@style/nowCardStyle"
                        android:layout_width="match_parent"
                        android:layout_height="100dp"
                        tools:context=".Chat"
                        android:layout_alignTop="@+id/linearLayout"
                        android:layout_alignLeft="@+id/linearLayout"/>

            </com.linkr.chat.NowLayout>
        </ScrollView>



        <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="10dp"
                android:id="@+id/linearLayout">

            <EditText
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:inputType="textMultiLine"
                    android:ems="10"
                    android:id="@+id/chatTextArea"
                    android:layout_alignTop="@+id/sendButton"
                    android:layout_toLeftOf="@+id/sendButton"
                    android:layout_alignBottom="@+id/sendButton"
                    android:layout_alignLeft="@+id/scrollView"
                    android:enabled="false"
                    android:focusable="false"
                    android:hint="What's on your mind..."
                    android:visibility="visible"/>

            <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/sendButton"
                    android:gravity="bottom"
                    android:background="@drawable/social_send_now"
                    android:onClick="sendMethod"
                    android:layout_alignBottom="@+id/scrollView"
                    android:layout_alignRight="@+id/scrollView"/>

        </LinearLayout>

    </RelativeLayout>


    <!-- The navigation drawer -->

    <!--<ImageView
        android:id="@+id/drawerimage"
        android:layout_width="320dp"
        android:layout_height="100dp"
        android:layout_gravity="start"
        android:background="@drawable/desert"
        android:choiceMode="singleChoice"></ImageView>-->
    <ListView
            android:id="@+id/drawer"
            android:layout_width="320dp"
            android:layout_height="match_parent"
            android:background="#F3F3F4"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:hint="What's on your mind?"
            android:divider="@android:color/darker_gray"
            android:dividerHeight="1dp" ></ListView>

</android.support.v4.widget.DrawerLayout>

这是应用程序

我希望你能帮助我非常感谢!

4

1 回答 1

0

You haven't said what is happening so its hard to say what the problem is. However, yo make this the way it sounds you want I would suggest adding the property

android:layout_alignParentBottom="true"

to your LineareLayout with the EditText and the Button. See if that works. Something like

<LinearLayout
     android:layout_width="wrap_content"
     android:layout_height="10dp"
     android:id="@+id/linearLayout"
     android:layout_alignParentBottom="true">   <!-- Add this line here -->

The parent of your EditText and Button is a LinearLayout but they have properties such as these

android:layout_alignTop="@+id/sendButton"
android:layout_toLeftOf="@+id/sendButton"
android:layout_alignBottom="@+id/sendButton"
 android:layout_alignLeft="@+id/scrollView"

but these are properties of a RelativeLayout so they won't have any effect, at least not any wanted effect, on Views whos parent is a LinearLayout.

See The Docs for the properties that each ViewGroup has.

于 2013-08-26T01:02:50.537 回答