2

How does twitter app handle the onclick action on EditText whenever we want to write a tweet? I want to know this because it lets us make a neat user interface and we can manage layout space in a better way.

EditText 1

So my question is that when we click on the EditText, do they launch a new activity?

EditText 2

What I was able to do was that in my layout XML file, I wrote this EditText which moves above the keyboard because of android:layout_alignParentBottom="true" Like

<EditText
    android:id="@+id/comment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textMultiLine"
    android:lines="5"
    android:singleLine="false"
    android:hint="Comment"
    android:layout_below="@+id/rlrate"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
     />

It looks alright but it still takes up space because it is multiline so I still want to know that whether they are starting a new activity with that layout to post a tweet or is it a fragment? If anyone can explain the functionality then it would be great.

Bhavyanshu
  • 536
  • 7
  • 25

1 Answers1

4

I don't think its the same activity.

I'd do it as follows:

Create EditText - aligned bottom, with an onClickListener. When someone clicks on it start a new Activity with animation - which would have a full screen EditText.

Edit For animating an Activity - i.e. it slides up when it starts like the Twitter app - then take a look at the answer by Mark Allison

Community
  • 1
  • 1
Zain
  • 2,336
  • 1
  • 16
  • 25
  • 1
    Full screen EditText with toolbar? That sounds good. Can you explain the animation part? Maybe with just code for onClickListener would do. – Bhavyanshu Jun 11 '15 at 20:46
  • 2
    I agree. I would treat it more like button to open another fragment or activity. I think it could be a Button rather than an EditText. – Eugene H Jun 11 '15 at 20:48
  • @Bhavyanshu Yes full screen EditText with a Toolbar. – Eugene H Jun 11 '15 at 20:50
  • @Bhavyanshu I've updated the answer above with a link to a good example of how to animate activities. – Zain Jun 12 '15 at 10:57
  • @Zain thanks. I implemented it yesterday only. Used a fragment with interface to send string back to parent activity. Actually i wanted to send string back to parent and not directly post like they do on twitter app. But thanks a lot for the idea. It was really helpful :) – Bhavyanshu Jun 12 '15 at 14:18