Как сделать так, чтобы представление edittext заполняло родительский элемент в Android

1

У меня есть два вида edittext. У одной из них есть только одна строка, ее название. Но другой должен заполнить линейный выход до конца, но это не так. Я обновил код, так что это весь мой xml для этого приложения. Надеюсь, кто-то может найти, что неправильно. Часть, которую я хочу сформировать, является частью внутри LinearLayout с именем addView.

<?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>

Теги:

3 ответа

1
Лучший ответ

Поэтому я нашел, что было не так. Мне нужно было установить layout_height (из представления textBoxContent) в 0dp и layout_weight (из вида textBoxContent) в 1.

1

Я изменил textBoxTitle height на wrap_content и я вижу следующее:

Изображение 174551

Это то, на что вы надеялись? Также, если вы хотите, чтобы content отображался в верхнем левом углу, используйте этот атрибут:

<EditText
    ...
    android:gravity="top"
    />
  • 0
    Это не сработало. Я обновил свой код, так что теперь вы можете увидеть весь мой XML. LinearLayout находится внутри FramLayout и в верхней части LinearLayout addView скользит влево, когда я нажимаю кнопку. Макет addView должен быть формой добавления заметки.
  • 0
    не важно, я нашел ответ
0

Первый вид должен иметь android: layout_width = "wrap_content"

Ещё вопросы

Сообщество Overcoder
Наверх
Меню