Topper Harley
Topper Harley

Reputation: 12384

How can I prevent the ActionBar from going out of the screen when scrolling a big EditText?

I've got this EditText:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <EditText
        android:id="@+id/text_editor"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="start|top"
        android:inputType="textLongMessage|textCapSentences|textMultiLine"
        android:textAlignment="gravity" />

</RelativeLayout>

I'm using the support ActionBarActivity, and this is what I have on my Nexus 5:

Half out of screen ActionBar

As you can see the ActionBar is slightly scrolled off screen. I've made a video that shows that.

I don't think this is the expected behavior, is it?
If it is, how can I prevent this? It seems very counter-intuitive.

Upvotes: 2

Views: 750

Answers (2)

Saurabh Singh
Saurabh Singh

Reputation: 1261

Just remove this attribute in your actionbar's xml:

app:layout_scrollFlags="scroll|enterAlways"

Upvotes: 0

adneal
adneal

Reputation: 30804

Wrap your EditText in a ScrollView.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <EditText
        android:id="@+id/text_editor"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="start|top"
        android:inputType="textLongMessage|textCapSentences|textMultiLine"
        android:textAlignment="gravity" />

</ScrollView>

Upvotes: 2

Related Questions