Android 相对长度内的线性布局?
我正在尝试构建一个应用程序,其中屏幕的左侧有一个图像,右侧有一个位置可以动态地在textview中写评论。 我在尝试将Linearlayout放置在Relativelayout中时遇到错误 以下是我的xml文件代码减去几个按钮:Android 相对长度内的线性布局?,android,android-layout,Android,Android Layout,我正在尝试构建一个应用程序,其中屏幕的左侧有一个图像,右侧有一个位置可以动态地在textview中写评论。 我在尝试将Linearlayout放置在Relativelayout中时遇到错误 以下是我的xml文件代码减去几个按钮: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" an
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<com.example.blueprintproj.PaintView
android:id="@+id/paintView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/loadButton"
android:background="@drawable/bp2" />
<Linearlayout
android:id="@+id/linearLayout"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<EditText
android:id="@+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add+"
/>
</Linearlayout>
请让我知道我做错了什么,或者如果您需要任何其他信息来指出问题
非常感谢你 拼写错误。。使用LinearLayout而不是LinearLayout拼写错误。。使用LinearLayout而不是LinearLayout尝试此操作,仅保留一个LinearLayout并将方向更改为水平,然后添加两个LinearLayout并更改宽度和重量,每一个如下所示:
android:layout_width="0dp"
android:layout_weight="1"
记住:您可以使用android:layout\u weight更改线性布局将填充屏幕的空间大小
如果在一个线性布局中输入weight=1,在另一个线性布局中输入weight=1,则总和将为2,因此第一个将填充屏幕的1/2,另一个为1/2,但如果将第二个更改为2,则总和将为3,因此第一个将填充屏幕的1/3,第二个将填充屏幕的2/3
出于性能原因,您可以设置android:layout\uuwieght=0dp,因为android:layout\uwieght将设置一个大小值,因此不需要向宽度中添加其他值
第二个布局将适合左侧的内容,第三个布局将适合右侧的内容。
希望它有帮助尝试此方法,只保留一个线性布局并将方向更改为水平,而不是添加两个线性布局并更改宽度和增加重量,如下所示:
android:layout_width="0dp"
android:layout_weight="1"
记住:您可以使用android:layout\u weight更改线性布局将填充屏幕的空间大小
如果在一个线性布局中输入weight=1,在另一个线性布局中输入weight=1,则总和将为2,因此第一个将填充屏幕的1/2,另一个为1/2,但如果将第二个更改为2,则总和将为3,因此第一个将填充屏幕的1/3,第二个将填充屏幕的2/3
出于性能原因,您可以设置android:layout\uuwieght=0dp,因为android:layout\uwieght将设置一个大小值,因此不需要向宽度中添加其他值
第二个布局将适合左侧的内容,第三个布局将适合右侧的内容。
希望有帮助但是如果我使用LinearLayout,它会给我一个错误,说方向不对?未指定方向,默认为水平,但此布局有多个子项,其中至少有一个子项具有布局\u宽度=匹配\u父项。您需要为LinearLayout指定方向根据您的要求尝试添加以下行android:orientation=水平或android:orientation=垂直您是英雄!你不知道我盯着xml看了多久,却没有看到它;但是如果我使用LinearLayout,它会给我一个错误,说方向不对?未指定方向,默认为水平,但此布局有多个子项,其中至少有一个子项具有布局\u宽度=匹配\u父项。您需要为LinearLayout指定方向根据您的要求尝试添加以下行android:orientation=水平或android:orientation=垂直您是英雄!你不知道我盯着xml看了多久,却没有看到它;