当前位置: 移动技术网 > 移动技术>移动开发>Android > Android:自定义layout 无法显示

Android:自定义layout 无法显示

2020年09月28日  | 移动技术网移动技术  | 我要评论
布局代码引入自定义layout如下所示: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/textview_description" android:orientation="vertical"> <com.change.de

布局代码引入自定义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

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网