0
我想我的包含我的EditText和ImageButton的RelativeLayout始終保持粘滯和全寬在鍵盤的頂部。RelativeLayout中的EditText粘在鍵盤上
顯示對話框時總是顯示鍵盤。
當您提交評論時,它應該看起來像YouTube應用程序的行爲。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Add anonymous comment"
android:textAppearance="@style/CodeFont" />
<ImageButton
android:id="@+id/submit_comment"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:background="@null"
android:scaleType="fitXY"
android:src="@drawable/send_red" />
</RelativeLayout>
DialogComment dialogComment = new DialogComment(mainActivity, WPPostDataView.this);
dialogComment.show();
//Grab the window of the dialog, and change the width
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
Window window = dialogComment.getWindow();
lp.copyFrom(window.getAttributes());
//This makes the dialog take up the full width
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(lp);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// request keyboard
this.getWindow().setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
這是近乎完美。我只需要LinearLayout上方的白色部分爲透明黑色(就像對話框中的空白空間) –
在上面創建一個linearLayout – Shanto
可以給我更多的細節嗎? –