FrameLayout的android:layout_height属性设置为dimen文件中的参数报错

通知栏布局错误解析
本文分析了一种在Android通知栏布局中出现的错误——当使用FrameLayout并设置layout_height为特定资源时,系统提示必须提供layout_height属性的问题。通过详细的错误日志,探讨了可能的原因及后续的研究方向。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:maxHeight="@dimen/notification_max_height"
    android:minHeight="@dimen/notification_min_height" >
以上是通知栏布局最外层用FrameLayout表示的正确代码,但如果把android:layout_height设置为@demen表示的参数,则即使此参数存在也会报如下错误,要求“You must supply a layout_height attribute”。

错误如下:
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: couldn't inflate view for notification com.abc/0x2

01-03 13:59:51.189 2586 2586 E PhoneStatusBar: java.lang.RuntimeException: Binary XML file line #2: You must supply a layout_height attribute.
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5644)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at android.view.ViewGroup$LayoutParams.<init>(ViewGroup.java:5596)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at com.android.internal.widget.SizeAdaptiveLayout$LayoutParams.<init>(SizeAdaptiveLayout.java:335)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at com.android.internal.widget.SizeAdaptiveLayout.generateLayoutParams(SizeAdaptiveLayout.java:284)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at com.android.internal.widget.SizeAdaptiveLayout.generateLayoutParams(SizeAdaptiveLayout.java:51)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at android.view.LayoutInflater.inflate(LayoutInflater.java:477)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at android.widget.RemoteViews.apply(RemoteViews.java:2283)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at com.android.systemui.statusbar.phone.PhoneStatusBar.inflateViews(PhoneStatusBar.java:4844)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at com.android.systemui.statusbar.phone.PhoneStatusBar.addNotificationViews(PhoneStatusBar.java:2137)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at com.android.systemui.statusbar.phone.PhoneStatusBar.addNotification(PhoneStatusBar.java:2015)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at com.android.systemui.statusbar.CommandQueue$H.handleMessage(CommandQueue.java:340)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at android.os.Handler.dispatchMessage(Handler.java:99)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at android.os.Looper.loop(Looper.java:137)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at android.app.ActivityThread.main(ActivityThread.java:5083)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at java.lang.reflect.Method.invokeNative(Native Method)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at java.lang.reflect.Method.invoke(Method.java:511)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-03 13:59:51.189 2586 2586 E PhoneStatusBar: at dalvik.system.NativeStart.main(Native Method)

01-03 13:59:51.189 2586 2586 W PhoneStatusBar: removeNotification for unknown key: android.os.BinderProxy@430a0aa0


具体原因暂时不明,可能是存在height冲突。原因还有待进一步研究。

我要处理一个大显示下的文本长度适配:不选择文件的情况下,在中文语言下显示正常,切换到文本较长的语言并且字体设置超大,显示设置较大后,文本会把按钮挤到屏幕边缘,怎么处理<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/dialog_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="@dimen/dimen_84dp" android:orientation="vertical"> <com.google.android.material.appbar.COUIDividerAppBarLayout android:id="@+id/appbar" style="@style/CommonAppBarStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/color_transparent" android:clickable="true" android:focusable="true" android:paddingLeft="@dimen/dimen_0dp" android:paddingRight="@dimen/dimen_0dp" app:elevation="@dimen/toolbar_elevation"> <com.coui.appcompat.toolbar.COUIToolbar android:id="@+id/toolbar" style="@style/COUIToolBarInAppBarLayoutStyle" android:layout_width="match_parent" android:background="@null" app:supportTitleTextAppearance="@style/textAppearanceSecondTitle" app:titleCenter="false" /> <com.coui.appcompat.tablayout.COUITabLayout android:id="@+id/tab_layout" android:background="@color/color_transparent" style="@style/COUISmallTabLayoutStyle" /> </com.google.android.material.appbar.COUIDividerAppBarLayout> <RelativeLayout android:id="@+id/content_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <com.filemanager.common.view.ViewPagerWrapperForPC android:id="@+id/view_pager_wrapper" android:layout_width="match_parent" android:layout_height="match_parent"> <com.filemanager.common.view.viewpager.RTLViewPager android:id="@+id/viewPager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/appbar" android:clipChildren="false" android:clipToPadding="false" android:orientation="horizontal" /> </com.filemanager.common.view.ViewPagerWrapperForPC> </RelativeLayout> </LinearLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="?attr/couiColorBackgroundElevatedWithCard" android:minHeight="@dimen/operation_btn_background_height"> <View android:id="@+id/button_divider" android:layout_width="match_parent" android:layout_height="@dimen/divider_background_height" android:layout_gravity="top" android:alpha="0" android:background="?attr/couiColorDivider" android:forceDarkAllowed="false" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <LinearLayout android:id="@+id/select_root_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginStart="@dimen/dimen_16dp" android:orientation="vertical"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:clickable="false" android:orientation="horizontal"> <TextView android:id="@+id/select_title_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/not_selected_file" android:textSize="16sp" android:lineHeight="22dp" android:textColor="?attr/couiColorLabelPrimary" android:textAppearance="@style/couiTextHeadlineXS" android:visibility="visible"/> <ImageView android:id="@+id/select_arraw_up" android:layout_width="18dp" android:layout_height="18dp" android:src="@drawable/arrow_up" android:layout_marginLeft="@dimen/dimen_6dp" android:visibility="gone" android:layout_gravity="center"/> </LinearLayout> <TextView android:id="@+id/select_body_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:lineHeight="20dp" android:textSize="14sp" android:textAppearance="?attr/couiTextBodyXS" android:textColor="?attr/couiColorLabelSecondary" android:visibility="gone" android:text="@string/selected_size"/> </LinearLayout> <View android:layout_width="0dp" android:layout_height="0dp" android:layout_weight="1"/> <com.coui.appcompat.button.COUIButton android:id="@+id/btn_add_file" style="@style/Widget.COUI.Button.Large" android:layout_width="@dimen/dimen_96dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginEnd="@dimen/dimen_16dp" android:text="@string/label_add_recent_file" /> </LinearLayout> </FrameLayout> </FrameLayout>
07-29
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <com.example.styledome.FullScreenVideoView android:id="@+id/video" android:layout_width="@dimen/dp_640" android:layout_height="@dimen/dp_370" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="@dimen/dp_370" android:layout_toRightOf="@id/video" android:orientation="vertical" android:background="@mipmap/bg_weather" > <TextView android:id="@+id/tv_date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/white" android:textSize="@dimen/sp_23" android:text="2025-06-09" android:layout_alignParentRight="true" android:layout_gravity="center" android:layout_marginTop="@dimen/dp_23" /> <TextView android:id="@+id/tv_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/white" android:text="7:00" android:textSize="@dimen/sp_40" android:layout_gravity="center" android:layout_marginTop="@dimen/dp_17" /> <ImageView android:id="@+id/iv_image" android:layout_width="@dimen/dp_130" android:layout_height="@dimen/dp_91" android:layout_gravity="center" android:layout_marginTop="@dimen/dp_9" android:src="@mipmap/duoyun" /> <TextView android:id="@+id/tv_weather" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/white" android:textSize="@dimen/sp_30" android:layout_gravity="center" android:text="晴转多云" android:layout_marginTop="@dimen/dp_19" /> <TextView android:id="@+id/tv_temperature" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/white" android:textSize="@dimen/sp_60" android:layout_gravity="center" android:text="24" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center" > <TextView android:id="@+id/tv_week" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginLeft="5dp" android:textColor="@color/white" android:visibility="gone" android:textSize="11sp" /> </LinearLayout> </LinearLayout> </RelativeLayout> <!-- <RelativeLayout android:layout_width="wrap_content" android:layout_height="@dimen/dp_67"> <ImageView android:layout_width="@dimen/dp_34" android:layout_height="@dimen/dp_31" android:layout_marginTop="@dimen/dp_16" android:layout_marginLeft="@dimen/dp_27" android:src="@mipmap/icon_bulletin" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@mipmap/bg_bulletin" android:layout_marginLeft="@dimen/dp_39" android:text="公交出行,节能减排,保护环境人人有责!" android:textColor="@color/white" android:textSize="@dimen/sp_36" android:gravity="center" /> </RelativeLayout>--> <com.example.styledome.VerticalMarqueeTextView android:id="@+id/tv_marquee" android:layout_width="40dp" android:layout_height="140dp" android:layout_gravity="top|start" android:background="#e0e0e0" android:textColor="#000" android:textSize="16sp" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/rec" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_16" android:layout_marginRight="@dimen/dp_16" android:layout_marginBottom="@dimen/dp_11" /> </LinearLayout>在所有布局值上显示 <com.example.styledome.VerticalMarqueeTextView android:id="@+id/tv_marquee" android:layout_width="40dp" android:layout_height="140dp" android:layout_gravity="top|start" android:background="#e0e0e0" android:textColor="#000" android:textSize="16sp" />
07-16
我希望实现这样一个效果,在我不断晚上滑动我的bottomsheet的时候,在准备到达顶部的时候,上面的刷新和zoom按钮能隐藏在cl_scroll_start_and_end后面,怎么弄androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="@+id/coordinator_bottom_sheet" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/tpds_transparent" app:layout_constraintBottom_toBottomOf="parent"> <com.tplink.design.card.TPConstraintCardView android:id="@+id/btn_refresh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="top|start" android:layout_margin="@dimen/tpds_all_dp_16" android:translationY="-16dp" app:cardCornerRadius="@dimen/tpds_all_dp_90" app:layout_anchor="@id/btn_zoom"> <ImageView android:id="@+id/iv_refresh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/tpds_all_dp_8" android:src="@drawable/mp_ad_svg_icon_refresh" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <com.tplink.design.indicator.TPLoadingIndicator android:id="@+id/loading_view" android:layout_width="0dp" android:visibility="gone" android:layout_height="wrap_content" app:layout_constraintBottom_toBottomOf="@id/iv_refresh" app:layout_constraintEnd_toEndOf="@id/iv_refresh" app:layout_constraintStart_toStartOf="@id/iv_refresh" app:layout_constraintTop_toTopOf="@id/iv_refresh" /> </com.tplink.design.card.TPConstraintCardView> <com.tplink.design.card.TPConstraintCardView android:id="@+id/btn_zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="start|top" android:layout_margin="@dimen/tpds_all_dp_16" app:cardCornerRadius="@dimen/tpds_all_dp_90" app:layout_anchor="@id/cl_bottom_sheet"> <ImageView android:id="@+id/iv_zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/tpds_all_dp_8" android:src="@drawable/mp_ad_svg_nav_zoom_24" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> </com.tplink.design.card.TPConstraintCardView> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/cl_bottom_sheet" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/tpds_transparent" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"> <com.tplink.design.card.TPConstraintCardView android:id="@+id/cv_room_card" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" android:layout_marginHorizontal="@dimen/tpds_all_dp_18" android:layout_marginTop="@dimen/tpds_all_dp_16" android:background="@color/tpds_white"> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/cl_headline" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="@dimen/tpds_all_dp_18"> <ImageView android:id="@+id/iv_cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="@dimen/tpds_all_dp_16" android:layout_marginEnd="@dimen/tpds_all_dp_16" android:src="@drawable/mp_ad_svg_icon_close_grey_16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/tv_conclusion" style="@style/TextAppearance.TPDesign.Body1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="@dimen/tpds_all_dp_16" android:layout_marginTop="@dimen/tpds_all_dp_16" android:text="@string/mp_ad_heatmap_homepage_room_report_title_well" app:layout_constraintEnd_toStartOf="@id/iv_cancel" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> <com.tplink.design.card.TPConstraintCardView android:id="@+id/card_weak_area" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="@dimen/tpds_all_dp_16" android:layout_marginTop="@dimen/tpds_all_dp_16" android:layout_marginEnd="@dimen/tpds_all_dp_6" android:layout_marginBottom="@dimen/tpds_all_dp_16" app:cardBackgroundColor="@color/tpds_gray_light" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@id/card_avg_signal" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cl_headline"> <TextView android:id="@+id/tv_weak_area" style="@style/TextAppearance.TPDesign.Caption" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/tpds_all_dp_16" android:layout_marginTop="@dimen/tpds_all_dp_16" android:text="@string/mp_ad_heatmap_homepage_room_report_signal_area" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/tv_weak_area_num" style="@style/TextAppearance.TPDesign.Headline6" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/tpds_all_dp_16" android:layout_marginTop="@dimen/tpds_all_dp_10" android:layout_marginBottom="@dimen/tpds_all_dp_16" android:text="@string/mp_ad_heatmap_homepage_room_report_signal_area_num" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_weak_area" /> </com.tplink.design.card.TPConstraintCardView> <com.tplink.design.card.TPConstraintCardView android:id="@+id/card_avg_signal" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="@dimen/tpds_all_dp_6" android:layout_marginTop="@dimen/tpds_all_dp_16" android:layout_marginEnd="@dimen/tpds_all_dp_16" android:layout_marginBottom="@dimen/tpds_all_dp_16" app:cardBackgroundColor="@color/tpds_gray_light" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/card_weak_area" app:layout_constraintTop_toBottomOf="@id/cl_headline"> <TextView android:id="@+id/tv_avg_signal" style="@style/TextAppearance.TPDesign.Caption" android:singleLine="true" android:maxLines="1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/tpds_all_dp_16" android:layout_marginTop="@dimen/tpds_all_dp_16" android:text="@string/mp_ad_heatmap_homepage_room_report_avg_strength" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/tv_avg_signal_num" style="@style/TextAppearance.TPDesign.Headline6" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/tpds_all_dp_16" android:layout_marginTop="@dimen/tpds_all_dp_10" android:layout_marginBottom="@dimen/tpds_all_dp_16" android:text="@string/mp_ad_heatmap_homepage_room_report_avg_strength_num" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tv_avg_signal" /> </com.tplink.design.card.TPConstraintCardView> </com.tplink.design.card.TPConstraintCardView> <ImageView android:id="@+id/iv_bottom_sheet_indicator" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/mp_ad_svg_fold_icon" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <com.tplink.design.card.TPConstraintCardView android:id="@+id/cl_scroll_start_and_end" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="@dimen/tpds_all_dp_16" app:layout_constraintCircleRadius="@dimen/tpds_all_dp_16" app:cardCornerRadius="@dimen/tpds_all_dp_16" app:layout_constraintTop_toBottomOf="@id/iv_bottom_sheet_indicator" > <androidx.core.widget.NestedScrollView android:id="@+id/scroll_start_and_end" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <com.tplink.design.card.TPConstraintCardView android:layout_width="match_parent" android:layout_height="wrap_content" app:cardBackgroundColor="@color/tpds_gray_light" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent">
最新发布
10-25
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值