android.graphics.Rect类的详解

本文详细介绍了 Android 中 Rect 类的使用方法及其与 RectF 类的区别。包括构造方法、常见方法如 contains、intersect 和 union 的说明,并解释了如何创建及操作矩形。

标签: AndroidRect

  分类:
 
public final class

Rect

extends  Object
implements  Parcelable
java.lang.Object
   ↳ android.graphics.Rect
Public Constructors
Rect()
Create a new empty Rect.
Rect(int left, int top, int right, int bottom)
Create a new rectangle with the specified coordinates.
Rect( Rect r)
Create a new rectangle, initialized with the values in the specified rectangle (which is left unmodified).
Public Methods
final int centerX()获取矩阵中心点(x,y)
final int centerY()
boolean contains(int x, int y)是否包含(x,y)点
Returns true if (x,y) is inside the rectangle.
boolean contains(int left, int top, int right, int bottom)是否包含(int left, int top, int right, int bottom)矩阵
Returns true iff the 4 specified sides of a rectangle are inside or equal to this rectangle.
boolean contains( Rect r)
Returns true iff the specified rectangle r is inside or equal to this rectangle.
int describeContents()
Parcelable interface methods
boolean equals( Object obj)
Compares this instance with the specified object and indicates if they are equal.
final float exactCenterX()该方法和CenterX()类似,只是该方法精确度比它高(返回float类型)
final float exactCenterY()
String flattenToString()
Return a string representation of the rectangle in a well-defined format.
final int height()
void inset(int dx, int dy)
Inset the rectangle by (dx,dy).
boolean intersect( Rect r)
If the specified rectangle intersects this rectangle, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle.
boolean intersect(int left, int top, int right, int bottom)
If the rectangle specified by left,top,right,bottom intersects this rectangle, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle.
boolean intersects(int left, int top, int right, int bottom)
Returns true if this rectangle intersects the specified rectangle.
static boolean intersects( Rect a,  Rect b)
Returns true iff the two specified rectangles intersect.
final boolean isEmpty()
Returns true if the rectangle is empty (left >= right or top >= bottom)
void offset(int dx, int dy)该矩阵在x轴和y轴分别发生的偏移量(很有用,可以上下移动矩阵)
Offset the rectangle by adding dx to its left and right coordinates, and adding dy to its top and bottom coordinates.
void offsetTo(int newLeft, int newTop)保持矩阵的宽高,矩阵的左上角偏移到(newLeft,newTop)该点
Offset the rectangle to a specific (left, top) position, keeping its width and height the same.
void readFromParcel( Parcel in)
Set the rectangle's coordinates from the data stored in the specified parcel.
void set(int left, int top, int right, int bottom)
Set the rectangle's coordinates to the specified values.
void set( Rect src)
Copy the coordinates from src into this rectangle.
void setEmpty()
Set the rectangle to (0,0,0,0)
boolean setIntersect( Rect a,  Rect b)
If rectangles a and b intersect, return true and set this rectangle to that intersection, otherwise return false and do not change this rectangle.
void sort()
Swap top/bottom or left/right if there are flipped (i.e.
String toShortString()
Return a string representation of the rectangle in a compact form.
String toString()
Returns a string containing a concise, human-readable description of this object.
static  Rect unflattenFromString( String str)
Returns a Rect from a string of the form returned by  flattenToString(), or null if the string is not of that form.
void union(int left, int top, int right, int bottom)
Update this Rect to enclose itself and the specified rectangle.
void union( Rect r)
Update this Rect to enclose itself and the specified rectangle.
void union(int x, int y)
Update this Rect to enclose itself and the [x,y] coordinate.
final int width()
void writeToParcel( Parcel out, int flags)
Write this rectangle to the specified parcel.

1.   new Rect(150, 75, 260, 120)  

  这个构造方法需要四个参数这四个参数 指明了什么位置 ?我们就来解释怎么画 这个 矩形 
这四个 参数 分别代表的意思是:left   top   right   bottom  上下左右呗。啊,不是     下。 下面给大家解释  
left  矩形左边的X坐标  150  
top:    矩形顶部的Y坐标   75     
right :  矩形右边的X坐标   260    
bottom 矩形底部的Y坐标 120    

说白了就是左上角的坐标是(150,75),右下角的坐标是(260,120),这样就好理解了


2、Rect类与RectF类(android.graphics.RectF)的区别??
答:主要还是在精度上的不同,他们分别是:int、float类型的
详解下面的代码:package com.example.bulbpage.bulbcontrol import android.content.Context import android.graphics.* import android.util.AttributeSet import android.view.MotionEvent import android.view.View import android.widget.SeekBar import com.example.bulbpage.R class LampProgressView(context: Context, attrs: AttributeSet) : View(context, attrs) { private var progress = 0f private val paint = Paint() private var bitmap: Bitmap? = null private var seekBar: SeekBar? = null init { bitmap = BitmapFactory.decodeResource(resources, R.drawable.bulbonbody) // 设置点击/滑动事件 isClickable = true isFocusable = true } fun setProgress(newProgress: Float) { this.progress = newProgress.coerceIn(0f..1f) invalidate() } override fun onTouchEvent(event: MotionEvent): Boolean { when (event.action) { MotionEvent.ACTION_DOWN, MotionEvent.ACTION_MOVE -> { val touchY = event.y val height = height.toFloat() // 计算进度(从下往上) progress = 1 - (touchY / height) progress = progress.coerceIn(0f..1f) // 更新 SeekBar 的进度 seekBar?.progress = (progress * seekBar?.max?.toFloat()!!).toInt() invalidate() return true } } return super.onTouchEvent(event) } override fun onDraw(canvas: Canvas) { super.onDraw(canvas) val bitmap = bitmap ?: return // 1. 计算要显示的源图像区域(从下往上) val showHeight = (bitmap.height * progress).toInt() val srcRect = Rect( 0, bitmap.height - showHeight, bitmap.width, bitmap.height ) // 2. 计算目标区域(保持图片宽高比,居中绘制) val intrinsicWidth = bitmap.width val intrinsicHeight = bitmap.height val scale = width / intrinsicWidth.toFloat() val scaledHeight = intrinsicHeight * scale val top = height - (scaledHeight * progress) val dstRect = RectF( 0f, top, width.toFloat(), height.toFloat() ) // 3. 绘制裁剪后的图像 canvas.drawBitmap(bitmap, srcRect, dstRect, paint) } }
08-19
2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for user 0 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for any user 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for user 0 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for any user 2025-09-03 20:54:02.033 718-858 InputDispatcher system_server E channel '6a720b8 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 21:00:20.868 718-858 InputDispatcher system_server E channel '207de1e com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 21:05:38.221 718-858 InputDispatcher system_server E channel 'c1f632b com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-07 20:44:52.229 1830-1942 .apps.wellbeing com.google.android.apps.wellbeing E Failed to open APK '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk': I/O error 2025-09-07 20:44:52.232 1830-1942 .apps.wellbeing com.google.android.apps.wellbeing E Failed to open APK '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk': I/O error 2025-09-07 20:44:52.232 1830-1942 ResourcesManager com.google.android.apps.wellbeing E failed to add asset path '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk' java.io.IOException: Failed to load asset path /data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk at android.content.res.ApkAssets.nativeLoad(Native Method) at android.content.res.ApkAssets.<init>(ApkAssets.java:322) at android.content.res.ApkAssets.loadFromPath(ApkAssets.java:171) at android.app.ResourcesManager.loadApkAssets(ResourcesManager.java:618) at android.app.ResourcesManager$ApkAssetsSupplier.load(ResourcesManager.java:287) at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:714) at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:801) at android.app.ResourcesManager.findOrCreateResourcesImplForKeyLocked(ResourcesManager.java:854) at android.app.ResourcesManager.createResources(ResourcesManager.java:1199) at android.app.ResourcesManager.getResources(ResourcesManager.java:1301) at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2979) at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:2154) at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:2140) at android.app.ApplicationPackageManager.getText(ApplicationPackageManager.java:2481) at android.content.pm.PackageItemInfo.loadUnsafeLabel(PackageItemInfo.java:237) at android.content.pm.PackageItemInfo.loadLabel(PackageItemInfo.java:226) at android.app.ApplicationPackageManager.getApplicationLabel(ApplicationPackageManager.java:2526) at cut.c(PG:38) at cfv.apply(PG:391) at e$$ExternalSyntheticApiModelOutline1.m(D8$$SyntheticClass:47) at lcx.accept(PG:44) at j$.util.stream.M0.accept(SourceFile:3) at j$.util.D.x(SourceFile:24) at j$.util.T.forEachRemaining(SourceFile:24) at j$.util.stream.b.c(SourceFile:21) at j$.util.stream.b.y(SourceFile:8) at j$.util.stream.F.b(SourceFile:5) at j$.util.stream.b.f(SourceFile:35) at j$.util.stream.c1.collect(SourceFile:83) at bva.a(PG:99) at kbp.a(PG:301) at kbp.a(PG:38) at ltp.a(PG:3) at lsv.run(PG:19) at ltr.run(PG:5) at lrz.run(PG:17) at idd.run(PG:3) at loz.run(PG:50) at hsu.run(PG:768) at java.lang.Thread.run(Thread.java:1119) at ieo.run(PG:63) 2025-09-07 20:47:00.731 718-858 InputDispatcher system_server E channel 'd671972 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-07 20:52:16.888 718-858 InputDispatcher system_server E channel '54ceef5 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:19:19.039 718-858 InputDispatcher system_server E channel 'da9443c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:28:44.520 718-858 InputDispatcher system_server E channel 'fb3dc4e com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:31:15.953 718-858 InputDispatcher system_server E channel '50c58e2 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 09:08:31.738 718-1763 TransitionController system_server E Set visible without transition ActivityRecord{10540855 u0 com.example.myapplication/.MainActivity t25} playing=true caller=com.android.server.wm.TaskFragment.resumeTopActivity:1629 2025-09-10 09:46:26.507 718-858 InputDispatcher system_server E channel 'dc063cb com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 08:57:50.144 718-858 InputDispatcher system_server E channel '1f6629d com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:00:15.359 718-858 InputDispatcher system_server E channel 'b8ebe12 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:08:43.780 718-858 InputDispatcher system_server E channel 'b3a4af9 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:09:46.460 718-858 InputDispatcher system_server E channel 'e65939a com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:10:18.549 718-858 InputDispatcher system_server E channel '97c3cce com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:10:20.415 718-858 InputDispatcher system_server E channel '4a4890c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:15:34.082 718-858 InputDispatcher system_server E channel '5112bb7 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:20:13.015 718-858 InputDispatcher system_server E channel 'd3fcd81 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:21:45.786 718-858 InputDispatcher system_server E channel '83178b7 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:40:09.328 718-858 InputDispatcher system_server E channel 'b88d2d6 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:06:13.033 13959-13959 TransactionExecutor pid-13959 E Failed to execute the transaction: tId:-782804407 ClientTransaction{ tId:-782804407 transactionItems=[ tId:-782804407 LaunchActivityItem{activityToken=android.os.BinderProxy@be43358,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 xflg=0x4 cmp=com.example.myapplication/.MainActivity },ident=184265485,info=ActivityInfo{a09354c com.example.myapplication.MainActivity},curConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.535 fontWeightAdjustment=0},overrideConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.2 fontWeightAdjustment=0},deviceId=0,referrer=com.android.shell,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@456b8d9,shareableActivityToken=android.os.BinderProxy@615029e,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1080, 2400), taskFragmentBounds=Rect(0, 0 - 1080, 2400)}} tId:-782804407 ResumeActivityItem{mActivityToken=android.os.BinderProxy@be43358,procState=-1,isForward=true,shouldSendCompatFakeFocus=false} tId:-782804407 Target activity: com.example.myapplication.MainActivity tId:-782804407 ] tId:-782804407 } 2025-09-22 17:06:13.036 13959-13959 AndroidRuntime pid-13959 E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 13959 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222) at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133) at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at com.example.myapplication.MainActivity.setButtonListeners(MainActivity.java:107) at com.example.myapplication.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:9155) at android.app.Activity.performCreate(Activity.java:9133) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262) ... 13 more 2025-09-22 17:08:39.215 14080-14080 TransactionExecutor pid-14080 E Failed to execute the transaction: tId:1940201582 ClientTransaction{ tId:1940201582 transactionItems=[ tId:1940201582 LaunchActivityItem{activityToken=android.os.BinderProxy@7091517,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 xflg=0x4 cmp=com.example.myapplication/.MainActivity },ident=36553713,info=ActivityInfo{8c6a69b com.example.myapplication.MainActivity},curConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.536 fontWeightAdjustment=0},overrideConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.2 fontWeightAdjustment=0},deviceId=0,referrer=com.android.shell,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@a09354c,shareableActivityToken=android.os.BinderProxy@8f10995,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1080, 2400), taskFragmentBounds=Rect(0, 0 - 1080, 2400)}} tId:1940201582 ResumeActivityItem{mActivityToken=android.os.BinderProxy@7091517,procState=-1,isForward=true,shouldSendCompatFakeFocus=false} tId:1940201582 Target activity: com.example.myapplication.MainActivity tId:1940201582 ] tId:1940201582 } 2025-09-22 17:08:39.218 14080-14080 AndroidRuntime pid-14080 E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 14080 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222) at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133) at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at com.example.myapplication.MainActivity.setButtonListeners(MainActivity.java:107) at com.example.myapplication.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:9155) at android.app.Activity.performCreate(Activity.java:9133) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262) ... 13 more 2025-09-22 17:16:44.788 14174-14174 AndroidRuntime pid-14174 E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 14174 java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.TextView at com.example.myapplication.MainActivity.lambda$setButtonListeners$0$com-example-myapplication-MainActivity(MainActivity.java:41) at com.example.myapplication.MainActivity$$ExternalSyntheticLambda0.onClick(D8$$SyntheticClass:0) at android.view.View.performClick(View.java:8083) at android.view.View.performClickInternal(View.java:8060) at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0) at android.view.View$PerformClick.run(View.java:31549) at android.os.Handler.handleCallback(Handler.java:995) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) 2025-09-22 17:16:44.809 718-858 InputDispatcher system_server E channel '15505d9 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:23:26.582 718-858 InputDispatcher system_server E channel '7ce91bf com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:23:49.591 14368-14368 AndroidRuntime pid-14368 E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 14368 java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.TextView at com.example.myapplication.MainActivity.lambda$setButtonListeners$0$com-example-myapplication-MainActivity(MainActivity.java:41) at com.example.myapplication.MainActivity$$ExternalSyntheticLambda0.onClick(D8$$SyntheticClass:0) at android.view.View.performClick(View.java:8083) at android.view.View.performClickInternal(View.java:8060) at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0) at android.view.View$PerformClick.run(View.java:31549) at android.os.Handler.handleCallback(Handler.java:995) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) 2025-09-22 17:23:49.608 718-858 InputDispatcher system_server E channel '9cce75c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:32:56.477 14730-14730 e.myapplication com.example.myapplication I Late-enabling -Xcheck:jni 2025-09-22 17:32:56.504 14730-14730 e.myapplication com.example.myapplication I Using CollectorTypeCMC GC. 2025-09-22 17:32:56.505 14730-14730 e.myapplication com.example.myapplication W Unexpected CPU variant for x86: x86_64. Known variants: atom, sandybridge, silvermont, goldmont, goldmont-plus, goldmont-without-sha-xsaves, tremont, kabylake, alderlake, default 2025-09-22 17:32:56.517 14730-14730 nativeloader com.example.myapplication D Load libframework-connectivity-tiramisu-jni.so using APEX ns com_android_tethering for caller /apex/com.android.tethering/javalib/framework-connectivity-t.jar: ok 2025-09-22 17:32:56.731 14730-14730 nativeloader com.example.myapplication D Configuring clns-9 for other apk /data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/base.apk. target_sdk_version=36, uses_libraries=, library_path=/data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/lib/x86_64:/data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/base.apk!/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication 2025-09-22 17:32:56.737 14730-14730 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4c758) locale list changing from [] to [en-US] 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V Currently set values for: 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_pkgs=[] 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_values=[] 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in per-application setting 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V ANGLE allowlist from config: com.dreamgames.royalmatch com.dts.freefiremax com.dxx.firenow com.gramgames.mergedragons com.ludo.king com.mojang.minecraftpe com.my.defense com.nintendo.zaka com.os.airforce com.playrix.fishdomdd.gplay io.teslatech.callbreak jp.konami.prospia net.peakgames.toonblast 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in ANGLE allowlist or settings, returning default 2025-09-22 17:32:56.745 14730-14730 GraphicsEnvironment com.example.myapplication V Neither updatable production driver nor prerelease driver is supported. 2025-09-22 17:32:56.799 14730-14766 DisplayManager com.example.myapplication I Choreographer implicitly registered for the refresh rate. 2025-09-22 17:32:56.802 14730-14730 e.myapplication com.example.myapplication I AssetManager2(0x79d591a488d8) locale list changing from [] to [en-US] 2025-09-22 17:32:56.834 14730-14766 EGL_emulation com.example.myapplication I Opening libGLESv1_CM_emulation.so 2025-09-22 17:32:56.835 14730-14766 EGL_emulation com.example.myapplication I Opening libGLESv2_emulation.so 2025-09-22 17:32:56.841 14730-14766 HWUI com.example.myapplication W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2025-09-22 17:32:56.841 14730-14766 HWUI com.example.myapplication W Failed to initialize 101010-2 format, error = EGL_SUCCESS 2025-09-22 17:32:56.881 14730-14730 AppCompatDelegate com.example.myapplication D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-09-22 17:32:56.883 14730-14730 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4f638) locale list changing from [] to [en-US] 2025-09-22 17:32:56.894 14730-14730 ashmem com.example.myapplication E Pinning is deprecated since Android Q. Please use trim or other methods. 2025-09-22 17:32:56.978 14730-14730 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:32:57.083 14730-14730 CompatChangeReporter com.example.myapplication D Compat change id reported: 377864165; UID 10217; state: ENABLED 2025-09-22 17:32:57.085 14730-14730 DesktopModeFlags com.example.myapplication D Toggle override initialized to: OVERRIDE_UNSET 2025-09-22 17:32:57.137 14730-14730 HWUI com.example.myapplication W Image decoding logging dropped! 2025-09-22 17:32:57.143 14730-14730 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:32:57.205 14730-14730 HWUI com.example.myapplication W Unknown dataspace 0 2025-09-22 17:32:57.499 14730-14730 InsetsController com.example.myapplication D hide(ime(), fromIme=false) 2025-09-22 17:32:57.499 14730-14730 ImeTracker com.example.myapplication I com.example.myapplication:120293d6: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN 2025-09-22 17:32:57.728 14730-14735 e.myapplication com.example.myapplication I Compiler allocated 5042KB to compile void android.view.ViewRootImpl.performTraversals() 2025-09-22 17:33:01.507 14730-14744 HWUI com.example.myapplication I Davey! duration=701ms; Flags=0, FrameTimelineVsyncId=339287, IntendedVsync=12434071552112, Vsync=12434071552112, InputEventId=0, HandleInputStart=12434073050000, AnimationStart=12434073070200, PerformTraversalsStart=12434073339500, DrawStart=12434073461500, FrameDeadline=12434104885444, FrameStartTime=12434073038200, FrameInterval=16666666, WorkloadTarget=16666666, SyncQueued=12434073835100, SyncStart=12434073973100, IssueDrawCommandsStart=12434074070700, SwapBuffers=12434077768700, FrameCompleted=12434772941900, DequeueBufferDuration=51900, QueueBufferDuration=249800, GpuCompleted=12434772941900, SwapBuffersCompleted=12434078695800, DisplayPresentTime=0, CommandSubmissionCompleted=12434077768700, 2025-09-22 17:33:01.516 14730-14730 Choreographer com.example.myapplication I Skipped 41 frames! The application may be doing too much work on its main thread. 2025-09-22 17:33:01.525 14730-14730 AssistStructure com.example.myapplication I Flattened final assist data: 3948 bytes, containing 1 windows, 27 views 2025-09-22 17:33:03.060 14730-14782 ProfileInstaller com.example.myapplication D Installing profile for com.example.myapplication 2025-09-22 17:34:16.254 718-858 InputDispatcher system_server E channel 'c4201b3 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:34:17.321 14830-14830 e.myapplication com.example.myapplication I Late-enabling -Xcheck:jni 2025-09-22 17:34:17.358 14830-14830 e.myapplication com.example.myapplication I Using CollectorTypeCMC GC. 2025-09-22 17:34:17.359 14830-14830 e.myapplication com.example.myapplication W Unexpected CPU variant for x86: x86_64. Known variants: atom, sandybridge, silvermont, goldmont, goldmont-plus, goldmont-without-sha-xsaves, tremont, kabylake, alderlake, default 2025-09-22 17:34:17.372 14830-14830 nativeloader com.example.myapplication D Load libframework-connectivity-tiramisu-jni.so using APEX ns com_android_tethering for caller /apex/com.android.tethering/javalib/framework-connectivity-t.jar: ok 2025-09-22 17:34:17.419 14830-14830 nativeloader com.example.myapplication D Load /data/user/0/com.example.myapplication/code_cache/startup_agents/3fc68f17-agent.so using system ns (caller=<unknown>): ok 2025-09-22 17:34:17.415 14830-14830 re-initialized> com.example.myapplication W type=1400 audit(0.0:2120): avc: granted { execute } for path="/data/data/com.example.myapplication/code_cache/startup_agents/3fc68f17-agent.so" dev="dm-55" ino=352933 scontext=u:r:untrusted_app:s0:c217,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c217,c256,c512,c768 tclass=file app=com.example.myapplication 2025-09-22 17:34:17.427 14830-14830 e.myapplication com.example.myapplication W hiddenapi: DexFile /data/data/com.example.myapplication/code_cache/.studio/instruments-c9b0d10a.jar is in boot class path but is not in a known location 2025-09-22 17:34:17.587 14830-14830 e.myapplication com.example.myapplication W Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled. 2025-09-22 17:34:17.587 14830-14830 e.myapplication com.example.myapplication W Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled. 2025-09-22 17:34:17.743 14830-14830 nativeloader com.example.myapplication D Configuring clns-9 for other apk /data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/base.apk. target_sdk_version=36, uses_libraries=, library_path=/data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/lib/x86_64:/data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/base.apk!/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication 2025-09-22 17:34:17.750 14830-14830 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4c758) locale list changing from [] to [en-US] 2025-09-22 17:34:17.752 14830-14830 e.myapplication com.example.myapplication I AssetManager2(0x79d591a46fd8) locale list changing from [] to [en-US] 2025-09-22 17:34:17.760 14830-14830 GraphicsEnvironment com.example.myapplication V Currently set values for: 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_pkgs=[] 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_values=[] 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in per-application setting 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V ANGLE allowlist from config: com.dreamgames.royalmatch com.dts.freefiremax com.dxx.firenow com.gramgames.mergedragons com.ludo.king com.mojang.minecraftpe com.my.defense com.nintendo.zaka com.os.airforce com.playrix.fishdomdd.gplay io.teslatech.callbreak jp.konami.prospia net.peakgames.toonblast 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in ANGLE allowlist or settings, returning default 2025-09-22 17:34:17.762 14830-14830 GraphicsEnvironment com.example.myapplication V Neither updatable production driver nor prerelease driver is supported. 2025-09-22 17:34:17.810 14830-14845 DisplayManager com.example.myapplication I Choreographer implicitly registered for the refresh rate. 2025-09-22 17:34:17.813 14830-14830 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4f638) locale list changing from [] to [en-US] 2025-09-22 17:34:17.842 14830-14845 EGL_emulation com.example.myapplication I Opening libGLESv1_CM_emulation.so 2025-09-22 17:34:17.842 14830-14845 EGL_emulation com.example.myapplication I Opening libGLESv2_emulation.so 2025-09-22 17:34:17.870 14830-14845 HWUI com.example.myapplication W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2025-09-22 17:34:17.870 14830-14845 HWUI com.example.myapplication W Failed to initialize 101010-2 format, error = EGL_SUCCESS 2025-09-22 17:34:17.889 14830-14830 AppCompatDelegate com.example.myapplication D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-09-22 17:34:17.890 14830-14830 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4da18) locale list changing from [] to [en-US] 2025-09-22 17:34:17.896 14830-14830 ashmem com.example.myapplication E Pinning is deprecated since Android Q. Please use trim or other methods. 2025-09-22 17:34:17.968 14830-14830 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:34:18.052 14830-14830 CompatChangeReporter com.example.myapplication D Compat change id reported: 377864165; UID 10217; state: ENABLED 2025-09-22 17:34:18.053 14830-14830 DesktopModeFlags com.example.myapplication D Toggle override initialized to: OVERRIDE_UNSET 2025-09-22 17:34:18.079 14830-14830 HWUI com.example.myapplication W Image decoding logging dropped! 2025-09-22 17:34:18.084 14830-14830 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:34:18.134 14830-14830 HWUI com.example.myapplication W Unknown dataspace 0 2025-09-22 17:34:18.402 14830-14830 InsetsController com.example.myapplication D hide(ime(), fromIme=false) 2025-09-22 17:34:18.403 14830-14830 ImeTracker com.example.myapplication I com.example.myapplication:a102fc0: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN 2025-09-22 17:34:18.561 14830-14835 e.myapplication com.example.myapplication I Compiler allocated 5042KB to compile void android.view.ViewRootImpl.performTraversals() 2025-09-22 17:34:20.485 14830-14830 AssistStructure com.example.myapplication I Flattened final assist data: 3948 bytes, containing 1 windows, 27 views 2025-09-22 17:34:22.900 14830-14859 ProfileInstaller com.example.myapplication D Installing profile for com.example.myapplication
最新发布
09-23
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值