提交 340e8c95 编写于 作者: B Blankj

see 08/18 log

上级 2679130d
......@@ -41,12 +41,11 @@ public final class ScreenUtils {
*/
public static int getScreenWidth() {
WindowManager wm = (WindowManager) Utils.getApp().getSystemService(Context.WINDOW_SERVICE);
if (wm == null) return -1;
Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//noinspection ConstantConditions
wm.getDefaultDisplay().getRealSize(point);
} else {
//noinspection ConstantConditions
wm.getDefaultDisplay().getSize(point);
}
return point.x;
......@@ -59,17 +58,42 @@ public final class ScreenUtils {
*/
public static int getScreenHeight() {
WindowManager wm = (WindowManager) Utils.getApp().getSystemService(Context.WINDOW_SERVICE);
if (wm == null) return -1;
Point point = new Point();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//noinspection ConstantConditions
wm.getDefaultDisplay().getRealSize(point);
} else {
//noinspection ConstantConditions
wm.getDefaultDisplay().getSize(point);
}
return point.y;
}
/**
* Return the application's width of screen, in pixel.
*
* @return the application's width of screen, in pixel
*/
public static int getAppScreenWidth() {
WindowManager wm = (WindowManager) Utils.getApp().getSystemService(Context.WINDOW_SERVICE);
if (wm == null) return -1;
Point point = new Point();
wm.getDefaultDisplay().getSize(point);
return point.x;
}
/**
* Return the application's height of screen, in pixel.
*
* @return the application's height of screen, in pixel
*/
public static int getAppScreenHeight() {
WindowManager wm = (WindowManager) Utils.getApp().getSystemService(Context.WINDOW_SERVICE);
if (wm == null) return -1;
Point point = new Point();
wm.getDefaultDisplay().getSize(point);
return point.y;
}
/**
* Return the density of screen.
*
......
......@@ -95,6 +95,8 @@ class ScreenActivity : BaseTitleActivity() {
SpanUtils.with(screenAboutTv)
.appendLine("getScreenWidth: " + ScreenUtils.getScreenWidth())
.appendLine("getScreenHeight: " + ScreenUtils.getScreenHeight())
.appendLine("getAppScreenWidth: " + ScreenUtils.getAppScreenWidth())
.appendLine("getAppScreenHeight: " + ScreenUtils.getAppScreenHeight())
.appendLine("getScreenDensity: " + ScreenUtils.getScreenDensity())
.appendLine("getScreenDensityDpi: " + ScreenUtils.getScreenDensityDpi())
.appendLine("isFullScreen: " + ScreenUtils.isFullScreen(this))
......
package com.blankj.utilcode.pkg.helper
import android.graphics.Bitmap
import android.graphics.drawable.ColorDrawable
import android.support.v7.app.AlertDialog
import android.text.method.ScrollingMovementMethod
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.Window
import android.widget.Button
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
import com.blankj.utilcode.pkg.R
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.KeyboardUtils
import com.blankj.utilcode.util.PermissionUtils
import com.blankj.utilcode.util.*
import com.blankj.utilcode.util.PermissionUtils.OnRationaleListener.ShouldRequest
import com.blankj.utilcode.util.ToastUtils
/**
* ```
......@@ -56,7 +56,9 @@ object DialogHelper {
val topActivity = ActivityUtils.getTopActivity()
if (!ActivityUtils.isActivityAlive(topActivity)) return
val dialogView = LayoutInflater.from(topActivity).inflate(R.layout.dialog_keyboard, null)
val dialog = AlertDialog.Builder(topActivity).setView(dialogView).create()
val dialog = AlertDialog.Builder(topActivity)
.setView(dialogView)
.create()
dialog.setCanceledOnTouchOutside(false)
val keyboardDialogEt = dialogView.findViewById<EditText>(R.id.keyboardDialogEt)
val listener = View.OnClickListener { v ->
......@@ -74,15 +76,18 @@ object DialogHelper {
dialogView.findViewById<View>(R.id.keyboardDialogShowSoftInputBtn).setOnClickListener(listener)
dialogView.findViewById<View>(R.id.keyboardDialogToggleSoftInputBtn).setOnClickListener(listener)
dialogView.findViewById<View>(R.id.keyboardDialogCloseBtn).setOnClickListener(listener)
dialog.show()
// val attributes = dialog.window.attributes
// attributes.y = SizeUtils.dp2px(300f)
// attributes.height = ScreenUtils.getScreenHeight() / 2
// dialog.window.attributes = attributes
// dialog.window.decorView.setPadding(0, 0, 0, 0)
val window = dialog.window
window.requestFeature(Window.FEATURE_NO_TITLE)
dialog.show()
KeyboardUtils.fixAndroidBug5497(dialog.window)
window.setBackgroundDrawable(ColorDrawable(0))
val attributes = dialog.window.attributes
attributes.gravity = Gravity.BOTTOM
attributes.width = ScreenUtils.getAppScreenWidth()
attributes.height = ScreenUtils.getAppScreenHeight() //* 2 / 5
dialog.window.attributes = attributes
}
fun showFragmentDialog(info: CharSequence) {
......
......@@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/mediumGray"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册