android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParam
来源:互联网 发布:万花成男捏脸数据 编辑:程序博客网 时间:2024/05/17 09:25
布局代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout02" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="250dp" android:id="@+id/linear_control_hor" android:orientation="horizontal">代码:
LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) LAdLiLayoutControl.getLayoutParams();linearParams.height = pxHeightValue;LAdLiLayoutControl.setLayoutParams(linearParams);
原因:控件 getLayoutParams() 获取的是父控件的LayoutParams,父控件就是上一级控件 RelaytiveLayout
修改为:
RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) LAdLiLayoutControl.getLayoutParams();
如果布局是:
<RelativeLayout android:layout_width="150dp" android:layout_height="250dp" android:id="@+id/L_bannerAD_ver_rl" android:visibility="visible"> <ImageView android:id="@+id/L_bannerAD_ver_img" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/advertise" android:scaleType="fitXY" android:adjustViewBounds="true"> </ImageView>那么imageview.getLayoutParams 是 RelativeLayout。
0 0
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParam
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParam
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParam
- android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutPara
- Android异常:RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
- LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams
- android.widget.FrameLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
- android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
- java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutPara
- ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsLis
- android.view.ViewGroup$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams
- ViewGroup$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams错误提示
- java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.w
- java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.w
- java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.w
- 径向模糊shader
- windows 的GPU版本tensorflow,keras,tensorlayer搭建
- Android NDK 编译出现 atomic :No such file or directory
- 持续集成之Jenkins+Gitlab简介 [一]
- Glide 加载GIF
- android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParam
- 各社交平台申请APPkey的网址及申请流程汇总
- android 区分wifi是5G还是2.4G
- 5.2
- java.lang.IllegalArgumentException
- kgdb 调试内核
- matlab和mod,rem的区别
- 选择排序之堆排序
- 在caffe中添加自定义的layer