В TableLayout TableRow выровнять кнопку правильно? - PullRequest
0 голосов
/ 08 марта 2012

Я пытаюсь выровнять кнопку справа от TableRow.Внутри TableRow у меня есть два просмотра текста и кнопка.Средний текстовый вид скрыт при отображении кнопки.Это делается в моем адаптере, устанавливая видимость textview как пропавшую.

Я не уверен, каков наилучший подход к выравниванию кнопки вправо, когда она отображается.

Вот мойФайл макета:

    <?xml version="1.0" encoding="UTF-8" ?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget28"
    android:stretchColumns="1"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:paddingLeft="10sp"
    android:descendantFocusability="blocksDescendants"
    >
    <TableRow>
    <TextView
     android:id="@+id/textTopLeft"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textAppearance="?android:attr/textAppearanceMedium">
    </TextView>
      <TextView
     android:id="@+id/textTopRight"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textAppearance="?android:attr/textAppearanceMedium">
    </TextView>
    </TableRow>
    <TableRow>
        <TextView
          android:id="@+id/textBottomLeft"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall">
        </TextView>
        <TextView
          android:id="@+id/textBottomRight"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall">
        </TextView>
        <Button
          android:id="@+id/btnSessionResume"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Resume"
          android:visibility="invisible"
          android:layout_marginRight="20px"
          android:layout_alignParentRight="true">
        </Button>
    </TableRow>
  </TableLayout>

Кнопка находится в нижней части TableRow.

Вот скриншот того, как выглядит макет в настоящее время:

enter image description here

Ответы [ 2 ]

0 голосов
/ 08 марта 2012

Возможно, вы можете иметь относительный макет в строке таблицы и затем использовать android: layout_alignParentLeft для TextViews и android: layout_alignParentRight для кнопки.

0 голосов
/ 08 марта 2012

// используйте android: layout_span и удалите правое поле для вас кнопкой

<?xml version="1.0" encoding="UTF-8" ?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget28"
    android:stretchColumns="1"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:paddingLeft="10sp"
    android:descendantFocusability="blocksDescendants"
    >
    <TableRow android:layout_width="fill_parent"
          android:layout_height="wrap_content" android:layout_span="2">
    <TextView
     android:id="@+id/textTopLeft"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textAppearance="?android:attr/textAppearanceMedium">
    </TextView>
      <TextView
     android:id="@+id/textTopRight"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textAppearance="?android:attr/textAppearanceMedium">
    </TextView>
    </TableRow>
   <TableRow android:layout_width="fill_parent"
          android:layout_height="wrap_content">
        <TextView
          android:id="@+id/textBottomLeft"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall">
        </TextView>
        <TextView
          android:id="@+id/textBottomRight"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceSmall">
        </TextView>
        <Button
          android:id="@+id/btnSessionResume"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Resume"
          android:visibility="invisible"
          android:layout_marginRight="5dp"
              android:layout_alignParentRight="true">
        </Button>
    </TableRow>
  </TableLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...