Подтвердить что ты не робот

Определение макета. Msgstr "Вы должны указать атрибут layout_width."

Я разрабатываю небольшое приложение для Android, и у меня проблема с макетом, я пытаюсь найти ошибку в моем xml, но я не смог ее найти...

Ошибка, которую я получаю, это "Вы должны указать атрибут layout_width", но я сделал это, и он все еще не работает...

Вот мой XML файл:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="100" >

    <TextView android:id="@+id/nombreEvento"
        android:layout_height="fill_parent"
        android:layout_weight="70"
    />

    <TextView android:id="@+id/moneda"
        android:layout_height="fill_parent"
        android:layout_weight="10"
    />

    <TextView android:id="@+id/totalEvento"
        android:layout_height="wrap_content"
        android:layout_weight="20"
    />
    </LinearLayout>

<TextView android:id="@+id/fecha"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>

</LinearLayout>
4b9b3361

Ответ 1

Нет, все ваши TextViews имеют layout_height и layout_weight вместо layout_height и layout_width (и, возможно, layout_weight). Попробуйте следующее:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="100" >

    <TextView android:id="@+id/nombreEvento"
        android:layout_height="fill_parent"
        android:layout_width="0dp"
        android:layout_weight="70"
    />

    <TextView android:id="@+id/moneda"
        android:layout_height="fill_parent"
        android:layout_width="0dp"
        android:layout_weight="10"
    />

    <TextView android:id="@+id/totalEvento"
        android:layout_height="wrap_content"
        android:layout_width="0dp"
        android:layout_weight="20"
    />
    </LinearLayout>

<TextView android:id="@+id/fecha"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>

</LinearLayout>

Ответ 2

Попробуйте добавить android:layout_width="wrap_content" в свои текстовые объекты, которые его не имеют.

Ответ 3

В моем случае я забыл поместить атрибут layout_width в TableLayout.

Немного сбивает с толку TableRow, который является дочерним элементом TableLayout, не требует макета, поэтому я столкнулся с этой проблемой...

Ответ 4

Вам нужно указать ширину и высоту представления. Это обязательно. Для textview вы устанавливаете только высоту и вес. Добавить

android:layout_width="0dip"