-1

i'm creating a console or terminal thing, and i'm having a problem. Normaly my Activity looks like this:

enter image description here

but when i click in the edittext and the keyboard opens my edittextfield and my send-button are gone: enter image description here

but i want the edittext and the sendbutton to be above the keybaord, so you see what you're typing and you're able to send it. This is my xml code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#d1d1d1">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="477dp"
        android:layout_below="@+id/title" >>
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:id="@+id/textView"
                android:text="Console:"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="0dip"
                android:gravity="top"
                android:textSize="20sp"
                android:textColor="#000000"
                android:typeface="monospace"
                android:paddingLeft="0dp"/>
        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="1">

        <EditText
            android:layout_marginLeft="5dp"
            android:layout_width="163dp"
            android:layout_height="wrap_content"
            android:id="@+id/consoleText"
            android:layout_weight="0.92" />

        <Button
            android:layout_width="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="5dp"
            android:layout_height="wrap_content"
            android:text="Send"
            android:id="@+id/sendButton"
            android:layout_gravity="right" />
    </LinearLayout>

</LinearLayout>

Maybe somebody knows, how i can fix this issue! Thanks in advance, any help is appreciated :)

N.W.A
  • 75
  • 1
  • 10

1 Answers1

1

Setting ScrollView's layout_weight=1 should work. Try this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#d1d1d1">

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/textView"
            android:text="Console:"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="0dip"
            android:gravity="top"
            android:textSize="20sp"
            android:textColor="#000000"
            android:typeface="monospace"
            android:paddingLeft="0dp"/>
    </LinearLayout>
</ScrollView>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:layout_marginLeft="5dp"
        android:layout_width="163dp"
        android:layout_height="wrap_content"
        android:id="@+id/consoleText"
        android:layout_weight="0.92" />

    <Button
        android:layout_width="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="5dp"
        android:layout_height="wrap_content"
        android:text="Send"
        android:id="@+id/sendButton"
        android:layout_gravity="right" />
</LinearLayout>

</LinearLayout>
jimmy0251
  • 16,293
  • 10
  • 36
  • 39
  • nice that worked, do you maybe know how i can jump/scroll to the end of the scrollview programmatically, because i'm appending text to this textview in my console and i want to sjump to the end of this textview inside my scrollview whenever i send a new command/press the button :) – N.W.A Jan 23 '16 at 19:54
  • Please check this http://stackoverflow.com/questions/3080402/android-scrollview-force-to-bottom for scrolling `ScrollView` to bottom. – jimmy0251 Jan 23 '16 at 20:10