Reputation: 3323
I have a problem with my layouting. In my layout I have an EditText, a DatePicker, a TimePicker and a Button. Clicking on the EditText opens the keyboard which causes the problem shown in the picture. Different methods from "android:windowSoftInputMode" did not change anything. Right now I do not have a clue how to tackle this problem.
Is it a good idea to hide the other components until a text is entered? What is the expected behaviour here?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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="patrickengelkes.com.alleneune.activities.CreateEventActivity">
<EditText
android:id="@+id/event_name_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<DatePicker
android:id="@+id/event_date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_name_edit_text"
android:layout_centerHorizontal="true" />
<Button
android:id="@+id/send_event_invites"
android:text="@string/send_event_invites_to_members"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TimePicker
android:id="@+id/event_time_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/send_event_invites"
android:layout_alignLeft="@+id/event_time_picker"
android:layout_alignStart="@+id/event_time_picker" />
Thanks in advance!
Upvotes: 1
Views: 722
Reputation: 857
I think the following is the problem:
You are telling your DatePicker
that it should be below the EditText
which is fixed at the top!
Then you are telling your TimerPicker
to be above your Button
which is fixed at the bottom.
Now when you open the SoftInput
the Button moves up, so does your TimePicker
. But the EditText stays fixed at top, so does your DatePicker
.
Both TimePicker
and DatePicker
got wrap_content
so the only way TimePicker
can go is into DatePicker
! And that's exactly what it looks like!
I would try to tell TimePicker
that i should stay below DatePicker
:
android:below=="@id/event_date_picker"
and see what happens! Because in that case it is forced to stay below DatePicker
and not acting like a layer anymore floating into DatePicker
! I didn't try it and maybe you need to declare android:windowSoftInputMode
correctly. Because i'm not sure how it is declared right now!
Hope it helps!
Upvotes: 1