从相对于线性变化的Andr​​oid布局 [英] Change Android layout from Relative to Linear

查看:152
本文介绍了从相对于线性变化的Andr​​oid布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始创建Android应用程序,但我有一个问题,修改布局,当我创建新的Andr​​oid项目每一次,它给了我 RelativeLayout的,而不是的LinearLayout 的,(当然,基本上我下面的这本书的指令,但它并没有教我如何去改变它)我想必须有一个默认设置,这样我可以修改 RelativeLayout的的LinearLayout

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
的xmlns:工具=htt​​p://schemas.android.com/tool​​s
机器人:layout_width =match_parent
机器人:layout_height =match_parent>

<的TextView
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_centerHorizo​​ntal =真
    机器人: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 in res 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 select LinearLayout as Root Element and give File Name. Press Finish
  • Now your Layout XML has the root element as LinearLayout

这篇关于从相对于线性变化的Andr​​oid布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆