Android:自定义layout 无法显示
程序员文章站
2022-03-15 10:23:58
布局代码引入自定义layout如下所示:
布局代码引入自定义layout如下所示:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textview_description"
android:orientation="vertical">
<com.change.demox.views.edittext.widget.InputEditTextView
android:id="@+id/user_name"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp" />
<com.change.demox.views.edittext.widget.InputEditTextView
android:id="@+id/phone_number"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp" />
</LinearLayout>
在运行时无法显示,用UI AutoMator抓取看,自定义控件绘制上去了,但是没有效果:
如果是这种情况,就要看自定义layout是否是利用inflate的方式动态加载出来的,原写法:
view = View.inflate(context, R.layout.common_edit_text_with_error_message, null)
改为:
view = View.inflate(context, R.layout.common_edit_text_with_error_message, this)
就能看到成功绘制了。
本文地址:https://blog.csdn.net/Crystal_xing/article/details/108845180
上一篇: MySQL如何判别InnoDB表是独立表空间还是共享表空间
下一篇: 风水角度谈买车
推荐阅读
-
Android编程实现自定义PopupMenu样式示例【显示图标与设置RadioButton图标】
-
Android自定义AvatarImageView实现头像显示效果
-
Android编程经典代码集锦(复制,粘贴,浏览器调用,Toast显示,自定义Dialog等)
-
详解 Android中Libgdx使用ShapeRenderer自定义Actor解决无法接收到Touch事件的问题
-
Android自定义AvatarImageView实现头像显示效果
-
Android自定义View实现仿驾考宝典显示分数效果(收藏)
-
详解 Android中Libgdx使用ShapeRenderer自定义Actor解决无法接收到Touch事件的问题
-
Android自定义ViewGroup实现堆叠头像的点赞Layout
-
Android自定义多节点进度条显示的实现代码(附源码)
-
Android自定义View实现仿驾考宝典显示分数效果(收藏)