Android - установить высоту списка - PullRequest
0 голосов
/ 15 марта 2012

У меня есть список, который находится в таблице.Данные отображаются, но я хочу, чтобы представление списка было «выше» (больше высоты), но я не могу понять, как это сделать.Я установил высоту в xml для всего (300dp, 500dp, wrap_content), но, похоже, это никак не влияет.Вот мой 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="horizontal" 
    android:background="#98c4ed">
 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:id="@+id/tableLayout"
      android:layout_height="wrap_content"
      android:shrinkColumns="1"
      android:layout_margin="5dp">
        <TableRow android:id="@+id/trSubStatus"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
            <TextView
                android:id="@+id/tvSubStatusLabel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Sub-Status:"
                style="@style/IssueDetailsLabelTextView" />
            <TextView
                android:id="@+id/tvSubStatus"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/IssueDetailsTextView" />
        </TableRow>
        <TableRow android:id="@+id/trDescription"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
            <TextView
                android:id="@+id/tvDescriptionLabel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Description:"
                style="@style/IssueDetailsLabelTextView" />
            <TextView
                android:id="@+id/tvDescription"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/IssueDetailsTextView" />
        </TableRow>
        <TableRow android:id="@+id/trActivities"
            android:layout_width="match_parent"
            android:layout_height="500dp"
            android:layout_marginTop="10dp">
            <TextView
                android:id="@+id/tvActivitiesLabel"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Issue Activities:"
                style="@style/IssueDetailsLabelTextView" />
            <ListView
                android:id="@+id/lvActivities"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"                
                android:background="#ffffff"
                android:cacheColorHint="#00000000">
            </ListView>
        </TableRow>
        <TableRow android:id="@+id/trLast"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20dp">
        </TableRow>
    </TableLayout>
</LinearLayout>

прямо сейчас, представление списка заполняется, но его высота меняется, и мне нужно прокрутить представление списка, чтобы увидеть больше.РЕДАКТИРОВАТЬ: Извините, хотел сказать, что у меня возникли проблемы с lvActivities в строке trActivities.

Редактировать: Мне бы хотелось, чтобы ListView был размером xx по высоте.Представление списка является последним элементом управления в макете, поэтому, если данные, помещенные в элементы управления над ним, позволяют макету превышать страницу, я бы хотел, чтобы страница прокручивалась, чтобы увидеть lvActivities.В настоящее время LlvActivities уменьшается или расширяется до размера страницы, и прокручивать lvActivities очень сложно, если он имеет высоту всего 1/2 дюйма (из-за данных в других элементах управления).

Ответы [ 2 ]

0 голосов
/ 07 октября 2013

Попробуйте это ->

list.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, theSizeIWant));

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

Почему бы вам не использовать android:minHeight, android:minWidth, android:maxHeight, android:maxWidth ??

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...