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.”

这样我们换回原来的主题,再看显示结果如图:

 

 

这样也可以将想要的结果显示出来。

 

转载于:https://www.cnblogs.com/xing1/p/9933680.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值