Skip to content

Commit

Permalink
修复因为输入法的弹出,Pudding被挤到了状态栏下面
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaochunyu committed Dec 24, 2019
1 parent 8efdf80 commit 936179d
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 61 deletions.
118 changes: 115 additions & 3 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions app/src/main/java/com/zcy/pudding/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@ package com.zcy.pudding.demo
import android.content.Intent
import android.graphics.Typeface
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.zcy.fancydialog.askDialog
import com.zcy.pudding.Pudding
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

editText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
Pudding.create(this@MainActivity) {
setTitle("This is Title")
}.show()
}

override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}

})
}

// 默认形式
Expand Down
110 changes: 53 additions & 57 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,131 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="@dimen/small_margin"
tools:context=".MainActivity">

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/default_pudding"
android:layout_margin="@dimen/small_margin"
android:onClick="click1"
android:textAllCaps="false"
/>
android:text="@string/default_pudding"
android:textAllCaps="false" />

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/color_background"
android:layout_margin="@dimen/small_margin"
android:onClick="click2"
android:textAllCaps="false"
/>
android:text="@string/color_background"
android:textAllCaps="false" />

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/icon_custom"
android:layout_margin="@dimen/small_margin"
android:onClick="click3"
android:textAllCaps="false"
/>
android:text="@string/icon_custom"
android:textAllCaps="false" />

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/verbose_text"
android:layout_margin="@dimen/small_margin"
android:onClick="click4"
android:textAllCaps="false"
/>
android:text="@string/verbose_text"
android:textAllCaps="false" />

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/infinite_pudding"
android:layout_margin="@dimen/small_margin"
android:onClick="click5"
android:textAllCaps="false"
/>
android:text="@string/infinite_pudding"
android:textAllCaps="false" />

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/loading"
android:layout_margin="@dimen/small_margin"
android:onClick="click6"
android:textAllCaps="false"
/>
android:text="@string/loading"
android:textAllCaps="false" />

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/swipe_dismiss"
android:layout_margin="@dimen/small_margin"
android:onClick="click8"
android:textAllCaps="false"
/>
android:text="@string/swipe_dismiss"
android:textAllCaps="false" />

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/listener"
android:layout_margin="@dimen/small_margin"
android:onClick="click9"
android:textAllCaps="false"
/>
android:text="@string/listener"
android:textAllCaps="false" />

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/with_button"
android:layout_margin="@dimen/small_margin"
android:onClick="click7"
android:textAllCaps="false"
/>
android:text="@string/with_button"
android:textAllCaps="false" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/small_margin"
android:layout_weight="1"
android:text="@string/start_dialog"
android:onClick="showAlertDialog"
android:textAllCaps="false"
/>
android:text="@string/start_dialog"
android:textAllCaps="false" />

<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/small_margin"
android:layout_weight="1"
android:text="@string/start_dialog_fancy"
android:onClick="showFancyDialog"
android:textAllCaps="false"
/>
android:text="@string/start_dialog_fancy"
android:textAllCaps="false" />
</LinearLayout>


<Button
android:layout_margin="@dimen/small_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/start_activity"
android:layout_margin="@dimen/small_margin"
android:onClick="startAnActivity"
android:textAllCaps="false"
/>
android:text="@string/start_activity"
android:textAllCaps="false" />

<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</LinearLayout>
</ScrollView>
4 changes: 3 additions & 1 deletion pudding/src/main/java/com/zcy/pudding/Pudding.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class Pudding : LifecycleObserver {
layoutParams.flags =
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or // 不获取焦点,以便于在弹出的时候 下层界面仍然可以进行操作
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or
WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR // 确保你的内容不会被装饰物(如状态栏)掩盖.
WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR or // 确保你的内容不会被装饰物(如状态栏)掩盖.
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM // 确保输入法弹出的时候不会被挤到状态栏下面

// popWindow的层级为 TYPE_APPLICATION_PANEL
layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL

Expand Down

0 comments on commit 936179d

Please sign in to comment.