从相对于线性变化的Android布局 [英] Change Android layout from Relative to Linear
本文介绍了从相对于线性变化的Android布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚开始创建Android应用程序,但我有一个问题,修改布局
,当我创建新的Android项目每一次,它给了我 RelativeLayout的
,而不是的LinearLayout
的,(当然,基本上我下面的这本书的指令,但它并没有教我如何去改变它)我想必须有一个默认设置,这样我可以修改 RelativeLayout的
到的LinearLayout
。
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<的TextView
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_centerHorizontal =真
机器人:layout_centerVertical =真
机器人:文本=@字符串/参考hello world
工具:上下文=。MainActivity/>
< / RelativeLayout的>
解决方案
要修改父
的布局的XML
文件请按照下列步骤操作:
- 右键单击您的
布局
文件夹RES
从项目文件夹中的文件夹 在月食。 (<项目文件夹/ RES /布局>
) - 选择选项
新建 - >其他...
。参见图: - 选择
Android的布局XML文件
从这里选择。 - preSS
下一页
,然后选择的LinearLayout
为根元素
并给文件名
。 preSS完成 - 现在,你的
布局XML
的根元素为的LinearLayout
I just started creating android apps, but i have a problem changing the layout
, every time when i create new android project , it gives me RelativeLayout
instead of LinearLayout
, (well, basically i am following the book instruction, but it doesn't teach me how to change it) I assume there must be a default setting so that i can change the Relativelayout
to LinearLayout
.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
解决方案
To change the Parent
of your layout XML
file follow these steps:
- Right click your
layout
folder inres
folder from project folder in eclipse. (<project-folder/res/layout>
) - Choose option
New -> Other...
. Refer picture: - Choose
Android Layout XML file
option from here. - Press
Next
and selectLinearLayout
asRoot Element
and giveFile Name
. Press Finish - Now your
Layout XML
has the root element asLinearLayout
这篇关于从相对于线性变化的Android布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文