Suh*_*aib 44 android android-studio android-relativelayout android-constraintlayout
我有最新的Android Studio(2.3 beta 3),看起来ConstraintLayout是创建项目时的默认设置.如何让Android Studio使用RelativeLayout作为新项目的默认布局元素?
小智 40
好吧,我看到了上面的答案,它也适用于我.但是,我给了它一个镜头,并成功将我当前的项目转换为相对布局.做如下:
在activity_main.xml选项卡上,将其更改为文本.在它的顶部,你会发现以下内容:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
Run Code Online (Sandbox Code Playgroud)
只需将xmlns之前的所有内容更改为RelativeLayout.这样做也会改变你会发现的最底线:
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
至
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
问题解决了!快乐:P
Har*_*ngh 14
我正在为android studio 2.3.1回答这个问题.将RelativeLayout设置为默认布局的最简单方法之一是进入文本模式并编辑XML文件,如下所示:
改变这一行:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
Run Code Online (Sandbox Code Playgroud)
至
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
并检查您的结束标记更改为:
</android.widget.RelativeLayout>
另外(可选)如果以灰色显示,则继续删除此行:
xmlns:app="http://schemas.android.com/apk/res-auto"
编辑:
这是项目中的可选更改,我在浏览Udacity的Android开发人员课程时遇到了这个提示
如果项目中不需要约束布局,则通过删除此行然后执行gradle sync来从build.gradle中删除以下依赖项:
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
Run Code Online (Sandbox Code Playgroud)
小智 13
Android studio 3.0
step0:
关闭android工作室
步骤1:
转到C:\ Program Files\Android\Android Studio\plugins\android\lib\templates\activities\common\root\res\layout \
第2步:
备份simple.xml.ftl
第3步:
将simple.xml.ftl更改为以下代码并保存:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="12dp"
android:layout_marginTop="21dp"
android:text="don't forget to click useful if this helps. this is my first post at stackoverflow!"
android:textSize="20sp"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
小智 10
对于android studio 3.1
如果你想要你的默认android工作室更改,请按照以下步骤操作:
第一
转到C:\ Program Files\Android\Android Studio\plugins\android\lib\templates\activities\common\root\res\layout
然后
从另一个地方复制simple.xml只是为了备份
之后
打开simple.xml文件并将其代码替换为下面的代码
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${packageName}.${activityClass}">
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但是如果你只是想改变这个项目布局,只需转到activity_main.xml,然后转到文本,然后转到上面的代码
小智 6
我认为您想更改android studio的默认设置。每当创建布局或活动时,默认情况下您要创建“ RelativeLayout”。在这种情况下,请执行以下步骤
你完成了
低效的解决方案:
归档时间: |
|
查看次数: |
89478 次 |
最近记录: |