android studio preview无法显示布局

jason_705 2015-11-25 10:29:12

为什么xml布局会报空指针,可是程序又没报错,可以正常运行,看不到界面...android新手求助啊!!
...全文
6711 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
le0102 2015-11-27
  • 打赏
  • 举报
回复
结贴给分,谢谢
黄小楼 2015-11-26
  • 打赏
  • 举报
回复
把绿色的小机器人图标23改成22或者更低
jason_705 2015-11-26
  • 打赏
  • 举报
回复
引用 8 楼 jklwan 的回复:
[quote=引用 7 楼 qq_32921625 的回复:] <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:background="#ADD8E6"> <com.rey.material.widget.Button android:id="@+id/id_login" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="登入" app:v_styleId="@array/button_raise_wave_color"/> </LinearLayout> </RelativeLayout>
这个com.rey.material.widget.Button控件的代码问题,在onAttachedToWindow中添加对isInEditMode的判断就行了,下载源码用导入library再引用,修改onAttachedToWindow代码如下
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    if(mStyleId != 0) {
        if(!isInEditMode()){
        ThemeManager.getInstance().registerOnThemeChangedListener(this);
        onThemeChanged(null);}
    }
}
[/quote] 实在太感谢你了!!已经可以了!大神,以后可不可以跟你混了
jklwan 2015-11-26
  • 打赏
  • 举报
回复
引用 7 楼 qq_32921625 的回复:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:background="#ADD8E6"> <com.rey.material.widget.Button android:id="@+id/id_login" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="登入" app:v_styleId="@array/button_raise_wave_color"/> </LinearLayout> </RelativeLayout>
这个com.rey.material.widget.Button控件的代码问题,在onAttachedToWindow中添加对isInEditMode的判断就行了,下载源码用导入library再引用,修改onAttachedToWindow代码如下
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    if(mStyleId != 0) {
        if(!isInEditMode()){
        ThemeManager.getInstance().registerOnThemeChangedListener(this);
        onThemeChanged(null);}
    }
}
jason_705 2015-11-26
  • 打赏
  • 举报
回复
引用 6 楼 jklwan 的回复:
[quote=引用 4 楼 qq_32921625 的回复:] 这该怎么解决?
布局的代码发一下[/quote] <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:background="#ADD8E6"> <include layout="@layout/activity_login_quick"/> <LinearLayout android:id="@+id/id_ll_main" android:layout_width="540dp" android:layout_height="240dp" android:layout_centerVertical="true" android:gravity="center" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="2" android:background="#FFFFFF" android:gravity="center" android:orientation="vertical"> <com.zl.view.DeleteEditText android:id="@+id/id_name" android:layout_width="512dp" android:layout_height="wrap_content" android:singleLine="true" android:hint="测试" android:background="@drawable/exittext" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#D6D6D6"/> <com.zl.view.DeleteEditText android:id="@+id/id_password" android:layout_width="match_parent" android:layout_height="match_parent" android:inputType="textPassword" android:background="@drawable/exittext" android:layout_gravity="center_horizontal" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#ADD8E6"/> <!--<Button--> <!--android:id="@+id/id_login"--> <!--android:layout_width="match_parent"--> <!--android:layout_height="0dp"--> <!--android:layout_weight="1"--> <!--android:text="登入"/>--> <com.rey.material.widget.Button android:id="@+id/id_login" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="登入" app:v_styleId="@array/button_raise_wave_color"/> </LinearLayout> </RelativeLayout>
jklwan 2015-11-26
  • 打赏
  • 举报
回复
引用 4 楼 qq_32921625 的回复:
这该怎么解决?
布局的代码发一下
jason_705 2015-11-26
  • 打赏
  • 举报
回复
引用 3 楼 jklwan 的回复:
应该是这个com.rey.material.app.ThemeManager.....的错误,是控件的问题,无法绘制出来。



这该怎么解决?
jason_705 2015-11-26
  • 打赏
  • 举报
回复


这该怎么解决?
jklwan 2015-11-26
  • 打赏
  • 举报
回复
应该是这个com.rey.material.app.ThemeManager.....的错误,是控件的问题,无法绘制出来。
jason_705 2015-11-26
  • 打赏
  • 举报
回复
有改过了 但是还是一样的

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧