Soft keyboard issure
I am trying to adjust my screen when the soft keyboard loads. The normal screen looks like this.
However when the user clicks the EditText, the view gets disrupted and appears like this. In my manifest for the activity I have added the following android:windowSoftInputMode="adjustResize"
What I would like to happen is that both the buttons at the bottom appear and the entire Edittext is visible without being cut when the user clicks on the EditText.
Edit: Adding the following line to my activity getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); made my view look like this. But I still want my two buttons to appear at the bottom of the EditText
XML for the bottom EditText and Buttons
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.6 "
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<EditText
android:hint="Enter your Message"
android:ems="10"
android:id="@+id/messageET"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<RelativeLayout
android:background="@drawable/lightrectangle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2.5">
<ImageButton
android:id="@+id/addimgbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#f6f6f6"
android:paddingLeft="10dp"
android:src="@mipmap/blueadd" />
<TextView
android:paddingLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Add an image"
android:id="@+id/textView4"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/addimgbtn"
/>
</RelativeLayout>
<RelativeLayout
android:background="@drawable/lightrectangle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2.5">
<ImageButton
android:id="@+id/sendbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="10dp"
android:layout_weight="2.5"
android:background="#f6f6f6"
android:src="@mipmap/bluesend" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Send Message"
android:id="@+id/sendmsgTV"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/sendbtn"
android:paddingLeft="10dp"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Add a the fields or layout inside a scroll view this will auto adjust your layout. You can scroll your layout and it is auto adjustable in all screens.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.6 "
android:background="#FFFFFF"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<EditText
android:id="@+id/messageET"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:ems="10"
android:hint="Enter your Message" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2.5"
android:background="@drawable/lightrectangle" >
<ImageButton
android:id="@+id/addimgbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#f6f6f6"
android:paddingLeft="10dp"
android:src="@mipmap/blueadd" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/addimgbtn"
android:paddingLeft="10dp"
android:text="Add an image"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2.5"
android:background="@drawable/lightrectangle" >
<ImageButton
android:id="@+id/sendbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_weight="2.5"
android:background="#f6f6f6"
android:paddingLeft="10dp"
android:src="@mipmap/bluesend" />
<TextView
android:id="@+id/sendmsgTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/sendbtn"
android:paddingLeft="10dp"
android:text="Send Message"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
链接地址: http://www.djcxy.com/p/93416.html
上一篇: 完全禁用editText软键盘
下一篇: 软键盘发行