Android Studio无法预览xml布局之解决方法(两种)
学习安卓程序开发,用的Android Studio,发现怎么更改xml代码都没有想要的效果。如图
 
代码如下:
<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
 
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/question" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/message" />
 
</LinearLayout>
 
参看了别人的博客,找到两种解决方式:
一:改变主题
圈中选项指示现在用的是什么主题,可以通过更改主题,来使xml布局可以被预览
 

好丑
二:通过改变配置文件中的内容
查看主配置文件如下,获取主题配置信息(文件名:AndroidManifest.xml)
 
然后找到所指示的文件
 
进行如下更改:
 
即在原来的parent属性值之前添加 “Base.”
这样我们换回原来的主题,再看显示结果如图:
 
这样也可以将想要的结果显示出来。
 
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号