赞
踩
此文适用于Android13:
在bom开发中,可能会遇到需要修改任何systemUI的地方,因此为了减少寻找文件的时间,和挨个试错的次数,这里讲提供较常用的布局修改,针对于锁屏界面的。
一、首先在锁屏界面,有通知和无通知是两种形式,如果有通知则是:
<!-- 这个是有通知情况下的时间界面-- 对应文件路径为:system/vendor/mediatek/proprietary/packages/apps/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml --> <FrameLayout android:id="@+id/lockscreen_clock_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_marginTop="20dp" > <com.android.keyguard.AnimatableClockView android:id="@+id/animatable_clock_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center_horizontal" android:textSize="@dimen/clock_text_size" android:fontFamily="@font/clock" android:elegantTextHeight="false" android:singleLine="true" android:fontFeatureSettings="pnum" chargeAnimationDelay="350" dozeWeight="200" lockScreenWeight="400" /> </FrameLayout>
二、如果没有通知
<!--如下是没有通知的情况下的时间界面 对应文件路径为:system/vendor/mediatek/proprietary/packages/apps/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml --> <LinearLayout android:id="@+id/keyguard_status_area" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:paddingTop="20dp" android:layout_below="@id/lockscreen_clock_view"> <include layout="@layout/keyguard_slice_view" android:id="@+id/keyguard_slice_view" android:layout_width="match_parent" android:layout_height="wrap_content" /> <com.android.systemui.statusbar.phone.NotificationIconContainer android:id="@+id/left_aligned_notification_icon_container" android:layout_width="match_parent" android:layout_height="@dimen/notification_shelf_height" android:paddingStart="@dimen/below_clock_padding_start_icons" android:visibility="invisible" /> </LinearLayout> <!--如下是具体时间界面的实现, 对应文件路径为:system/vendor/mediatek/proprietary/packages/apps/SystemUI/res-keyguard/layout/keyguard_slice_view.xml --> <com.android.keyguard.KeyguardSliceView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:clipToPadding="false" android:orientation="vertical" android:layout_marginBottom="30dp"> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone" android:textColor="?attr/wallpaperTextColor" android:theme="@style/TextAppearance.Keyguard" /> <view class="com.android.keyguard.KeyguardSliceView$Row" android:id="@+id/row" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" /> </com.android.keyguard.KeyguardSliceView>
三、锁定图标通过java文件进行位置控制
//如下文件是锁屏图标所在的布局的自定义布局,当前文件为:system/vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/keyguard/LockIconView.java public void setCenterLocation(@NonNull PointF center, float radius, int drawablePadding) { mLockIconCenter = center; mRadius = radius; mLockIconPadding = drawablePadding; mLockIcon.setPadding(mLockIconPadding, mLockIconPadding, mLockIconPadding, mLockIconPadding); // mSensorProps coordinates assume portrait mode which is OK b/c the keyguard is always in // portrait. mSensorRect.set(mLockIconCenter.x - mRadius, mLockIconCenter.y - mRadius, mLockIconCenter.x + mRadius, mLockIconCenter.y + mRadius); final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); lp.width = (int) (mSensorRect.right - mSensorRect.left); lp.height = (int) (mSensorRect.bottom - mSensorRect.top); //例如这里的需求是锁屏界面的锁定图标需要在顶部,因此把之前的改为70,定位就上去了 // lp.topMargin = (int) mSensorRect.top; lp.topMargin = 70; lp.setMarginStart((int) mSensorRect.left); setLayoutParams(lp); }
四、类似其他相关修改可以针对其相关的布局,例如调整图标大小
<!-- 此处为锁屏图标的实现,比如如果需要修改锁屏图标大小也只需要调整imageView大小即可 文件所在位置为:system/vendor/mediatek/proprietary/packages/apps/SystemUI/res/layout/status_bar_expanded.xml --> <com.android.keyguard.LockIconView android:id="@+id/lock_icon_view" android:layout_width="wrap_content" android:layout_height="wrap_content"> <!-- Background protection --> <ImageView android:id="@+id/lock_icon_bg" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/fingerprint_bg" android:visibility="invisible"/> <ImageView android:id="@+id/lock_icon" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" android:scaleType="centerCrop"/> </com.android.keyguard.LockIconView>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。