Skip to content

Commit 9162d80

Browse files
v1.0.2 新增Dialog模块
1 parent efd01b0 commit 9162d80

File tree

6 files changed

+102
-31
lines changed

6 files changed

+102
-31
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.meis.basemodule.dialog;
2+
3+
import android.graphics.drawable.ColorDrawable;
4+
import android.support.v4.content.ContextCompat;
5+
import android.view.Gravity;
6+
import android.view.Window;
7+
import android.view.WindowManager;
8+
9+
import com.meis.base.mei.dialog.BaseDialog;
10+
import com.meis.basemodule.R;
11+
12+
/**
13+
* desc: 以底部弹出评论提示框 可以解决很多软键盘与滚动界面冲突问题
14+
* author: ws
15+
* date: 2018/4/14.
16+
*/
17+
18+
public class BottomCommentDialog extends BaseDialog {
19+
20+
@Override
21+
protected int getLayoutId() {
22+
return R.layout.comm_bottom_comment;
23+
}
24+
25+
@Override
26+
protected void initView() {
27+
28+
}
29+
30+
@Override
31+
protected void initData() {
32+
33+
}
34+
35+
@Override
36+
public void onStart() {
37+
super.onStart();
38+
39+
Window window = getDialog().getWindow();
40+
WindowManager.LayoutParams params = window.getAttributes();
41+
// 显示在底部
42+
params.gravity = Gravity.BOTTOM;
43+
// 宽度填充满屏
44+
params.width = WindowManager.LayoutParams.MATCH_PARENT;
45+
//显示dialog的时候,就显示软键盘
46+
params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE;
47+
window.setAttributes(params);
48+
49+
// 这里用透明颜色替换掉系统自带背景
50+
int color = ContextCompat.getColor(getActivity(), android.R.color.transparent);
51+
window.setBackgroundDrawable(new ColorDrawable(color));
52+
}
53+
}

app/src/main/java/com/meis/basemodule/dialog/MainActivity.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ protected void initData() {
2222
showDialog(new CreateLiveDialog());
2323
}
2424

25-
public void clickLive(View v) {
25+
public void clickLive(View view) {
2626
showDialog(new CreateLiveDialog());
2727
}
2828

29+
public void clickComment(View view) {
30+
showDialog(new BottomCommentDialog());
31+
}
32+
2933
@Override
3034
protected int layoutResId() {
3135
return R.layout.activity_dialog;

app/src/main/res/layout/activity_dialog.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,14 @@
1515
android:text="@string/click_show_dialog"
1616
android:textAllCaps="false"/>
1717

18+
<Button
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:layout_marginBottom="24dp"
22+
android:layout_marginLeft="24dp"
23+
android:layout_marginRight="24dp"
24+
android:onClick="clickComment"
25+
android:text="@string/click_show_comment_dialog"
26+
android:textAllCaps="false"/>
27+
1828
</LinearLayout>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="wrap_content"
5+
android:layout_gravity="bottom"
6+
android:background="@android:color/white"
7+
android:orientation="horizontal"
8+
android:tag="input">
9+
10+
<EditText
11+
android:id="@+id/et_send"
12+
android:layout_width="0dp"
13+
android:layout_height="@dimen/bottombar_height"
14+
android:layout_marginLeft="8dp"
15+
android:layout_weight="1"
16+
android:background="@drawable/bg_chat_input"
17+
android:hint="@string/hint_im"
18+
android:singleLine="true"
19+
android:textSize="14sp"/>
20+
21+
<TextView
22+
android:id="@+id/btn_send"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:layout_gravity="center_vertical"
26+
android:paddingLeft="8dp"
27+
android:paddingRight="8dp"
28+
android:text="@string/send"
29+
android:textAllCaps="false"/>
30+
</LinearLayout>
31+

app/src/main/res/layout/zhihu_fragment_tab_first_msg.xml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,7 @@
1717
android:background="@android:color/white"/>
1818
</LinearLayout>
1919

20-
<LinearLayout
21-
android:layout_width="match_parent"
22-
android:layout_height="wrap_content"
23-
android:layout_gravity="bottom"
24-
android:background="@android:color/white"
25-
android:orientation="horizontal"
26-
android:paddingLeft="8dp"
27-
android:tag="input">
28-
29-
<EditText
30-
android:id="@+id/et_send"
31-
android:layout_width="0dp"
32-
android:layout_height="@dimen/bottombar_height"
33-
android:layout_weight="1"
34-
android:background="@drawable/bg_chat_input"
35-
android:hint="@string/hint_im"
36-
android:singleLine="true"
37-
android:textSize="14sp"/>
38-
39-
<TextView
40-
android:id="@+id/btn_send"
41-
android:layout_width="wrap_content"
42-
android:layout_height="wrap_content"
43-
android:layout_gravity="center_vertical"
44-
android:paddingLeft="8dp"
45-
android:paddingRight="8dp"
46-
android:text="@string/send"
47-
android:textAllCaps="false"/>
48-
</LinearLayout>
20+
<include layout="@layout/comm_bottom_comment"></include>
4921

5022
<ImageView
5123
android:layout_width="match_parent"

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@
5656
<string name="favorite">收藏</string>
5757
<string name="more">更多</string>
5858

59-
<string name="click_show_dialog">拖动的提示框</string>
59+
<string name="click_show_dialog">底部提示框</string>
60+
<string name="click_show_comment_dialog">底部评论提示框</string>
6061
</resources>

0 commit comments

Comments
 (0)