0

Имеется разметка:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*"
android:id="@+id/tableLayout"
android:background="#ff0000">
<TableRow
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:background="#00f">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TextView
            android:id="@+id/month_label_text_view"
            android:layout_height="match_parent"
            android:layout_width="wrap_content"/>
        <Button
            android:id="@+id/button_next_month"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="end"
            android:background="@drawable/arrow_right_large"/>
    </FrameLayout>
</TableRow>
<TableRow
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <TextView
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:background="#000"/>
</TableRow>
<TableRow
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <TextView
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:background="#fff"/>
</TableRow>

Выглядит это так:

введите сюда описание изображения

Как сделать, не меняя фоновой картинки кнопки, чтобы все 3 ряда имели одинаковую высоту, занимая весь экран?

2
  • попробуй поменять android:layout_height="0dp" на android:layout_height="match_parent" 8 мая 2016 в 16:05
  • @EugeneTroyanskii Попробовала - ничего не изменилось.
    – iramm
    8 мая 2016 в 17:39

2 ответа 2

2

С TableLayout с самого начала не подружился, но по опыту добавьте заглушку и раздайте дополнительные веса:

<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:shrinkColumns="*"
    android:stretchColumns="*"
    android:id="@+id/tableLayout"
    android:background="#ff0000">
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#00f">
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1">
            <TextView
                android:id="@+id/month_label_text_view"
                android:layout_height="match_parent"
                android:layout_width="match_parent"/>
            <Button
                android:id="@+id/button_next_month"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="end"
                android:background="@drawable/arrow_right_large"/>
        </FrameLayout>

        <TextView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="0"
            android:text="Dummy" />
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
        <TextView
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:background="#000"/>
    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
        <TextView
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:background="#fff"/>
    </TableRow>
</TableLayout>

Результат (добавил первую попавшуюся большую картинку из google):

введите сюда описание изображения

0

Я прислушалась к совету Android Studio о том, что что-то из TableRow или FrameLayout лишнее. Убрала TableRow, обрамляющий FrameLayout, задав FrameLayoutвес 1 и высоту 0dp. И все получилось)))

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.