Разметка Android для ListView с последующей полосой прокрутки текста внизу экрана
У меня проблемы с настройкой макета Android.
То, что я хотел бы, - это прокручиваемый ListView, за которым следует небольшая полоска текста (TextView), которая не прокручивается и всегда остается в нижней части экрана.
это будет выглядеть так:
ListViewItem1
ListViewItem2
ListViewItem3
...
Панель текста здесь (всегда отображается независимо от состояния прокрутки ListView)
Я пробовал несколько разных вариантов, но ни один не показывает статический текст
Есть мысли о том, где я иду не так?
TKS!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ListView android:id="@+id/list2" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="50dip" android:text="Bar of text that always stays at the bottom of the screen" />
</LinearLayout>
5 ответов
Использовать RelativeLayout
, Якорь TextView
на дно, используя android:layout_alignParentBottom="true"
, Есть ListView
заполните остаток.
Или используйте один LinearLayout
, установив ListView
"s android:layout_height
в 0px
а также android:layout_weight
в 1
и TextView
следуя ListView
как дети LinearLayout
,
Используйте android:layout_weight, чтобы ваш список заполнял оставшуюся часть страницы, не используемую статическим текстом.
вот так:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ListView android:id="@+id/list2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"/><!-- here's the important part-->
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Bar of text that always stays at the bottom of the screen" />
</LinearLayout>
На самом деле, это действительно звучит так, как будто вы хотите использовать нижний колонтитул, который ListView уже имеет и делает именно то, что вы описываете.
Основано на ответе @CommonsWare:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/actionsListView"
android:layout_height="0px"
android:layout_width="fill_parent"
android:layout_weight="1"
android:transcriptMode="alwaysScroll"/>
<TextView android:text=""
android:id="@+id/progressTextLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
</LinearLayout>
Попробуй это:
Надеюсь, поможет:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="420dp"
android:id="@+id/rel">
<ListView
android:id="@+id/list2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rel"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="fill_parent"
android:layout_height="50dip"
android:text="Bar of text that always stays at the bottom of the screen" />
</RelativeLayout>
</RelativeLayout>