为了账号安全,请及时绑定邮箱和手机立即绑定

我拖拉进去一个TextView为什么会多出来两行代码 ,而且安卓编辑界面也不一样,看着很难受?

<TextView

        android:id="@+id/textView1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_alignParentTop="true"

         android:text="TextView" />

http://img1.sycdn.imooc.com//593a015c000107a006040667.jpge"

正在回答

2 回答

已解决

首先先找到一个叫“activity_simple.xml.ftl”的文件,路径是\eclipse\sdk\tools\templates\activities\BlankActivity\root\res\layout
2.打开发现,它的布局就是RelativeLayout
3.接下来就是用下面的代码,代码:
<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:orientation="vertical"
   android:layout_width=<#if buildApi lt 8 >"fill_parent"<#else>"fill_parent"</#if>
   android:layout_height=<#if buildApi lt 8 >"fill_parent"<#else>"fill_parent"</#if> >

   <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/hello_world"
       tools:context=".${activityClass}" />

</LinearLayout>
,替换,就好了


1 回复 有任何疑惑可以回复我~

TextView的父控件是RelativeLayout

下面两个是RelativeLayout特有的属性

android:layout_alignParentLeft="true"  --将控件的左边缘和父控件的左边缘对齐
android:layout_alignParentTop="true"  --将控件的上边缘和父控件的上边缘对齐

0 回复 有任何疑惑可以回复我~
#1

刘飞_ 提问者

怎么变成视频里老师那样的,这样做出来在模拟器里显示布局有的时候也不整齐
2017-06-09 回复 有任何疑惑可以回复我~
#2

刘飞_ 提问者

或者说怎么将父类容器改为LinearLayout
2017-06-09 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Android攻城狮的第一门课(入门篇)
  • 参与学习       312506    人
  • 解答问题       4931    个

想快速掌握Android应用开发基础,选择学习这门课程就对了。

进入课程

我拖拉进去一个TextView为什么会多出来两行代码 ,而且安卓编辑界面也不一样,看着很难受?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号