Geo*_*Lim 9 android android-layout
我刚刚开始创建Android应用程序,但我有一个问题更改layout,每次当我创建新的Android项目,它给了我RelativeLayout而不是LinearLayout,(好吧,基本上我遵循书的指令,但它不教我如何改变它)我假设必须有一个默认设置,以便我可以更改Relativelayout为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>
Run Code Online (Sandbox Code Playgroud)
Lee*_*elo 19
替换以下标记:
<RelativeLayout
... >
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
由那些:
<LinearLayout
... >
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
此外,您应该从TextView属性中删除以下内容:
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
Run Code Online (Sandbox Code Playgroud)
因为它们适用于相对布局而不是线性布局.
要更改文件Parent,请按layout XML以下步骤操作:
layout文件夹中的res文件夹.(<project-folder/res/layout>)New -> Other....参考图片:
Android Layout XML file从这里选择选项.
Next然后选择LinearLayoutas Root Element并给出File Name.按完成
Layout XML的根元素为LinearLayout| 归档时间: |
|
| 查看次数: |
53667 次 |
| 最近记录: |