1

我有两个编辑文本视图。其中一个只有一行,它的标题。但是另一个应该将线性布局填充到最后,但事实并非如此。我更新了代码,所以这是这个应用程序的整个 xml。我希望有人能找出问题所在。我想要这样形成的部分是名为 addView 的 LinearLayout 内的部分。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
android:background="#ffffff">

<LinearLayout  
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="horizontal"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
>

    <Button 
        android:id="@+id/addButton"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@drawable/addbuttonstyle"
        android:layout_weight="20"/>

    <ImageView
        android:id="@+id/titleView"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@drawable/titleview"
        android:layout_weight="60"/>

    <Button 
        android:id="@+id/orderButton"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@drawable/orderbuttonstyle"
        android:layout_weight="20"/>

</LinearLayout>  

<FrameLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
> 
    <LinearLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/addView"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >

        <EditText 
            android:id="@+id/textBoxTitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:hint="note title"
            android:singleLine="true"

            />
         <EditText 
            android:id="@+id/textBoxContent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:hint="content"
            />
    </LinearLayout>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/backgroundLayout"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/background"
    />

</FrameLayout>

4

3 回答 3

1

我将textBoxTitle' 的高度更改为wrap_content,我看到了:

截屏

这是你所希望的吗?此外,如果您想出content现在左上角,请使用此属性:

<EditText
    ...
    android:gravity="top"
    />
于 2012-05-12T22:17:06.773 回答
1

所以我发现出了什么问题。我需要将 layout_height(textBoxContent 视图)设置为 0dp,将 layout_weight(textBoxContent 视图)设置为 1。

于 2012-05-13T13:59:12.977 回答
0

第一个视图应该有 android:layout_width="wrap_content"

于 2012-05-12T22:17:48.673 回答