私は上に何かを追加してリストビューの下にレイアウトする必要があるので、スクロールしたくないレイアウトを持っています。リストビューだけをスクロールしたい全画面をスクロールしたい私はこのコードを追加しました。それはここリストビューの下からアンドロイド
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null)
return;
int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED);
int totalHeight = 0;
View view = null;
for (int i = 0; i < listAdapter.getCount(); i++) {
view = listAdapter.getView(i, view, listView);
if (i == 0)
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ActionBar.LayoutParams.WRAP_CONTENT));
view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
totalHeight += view.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
}
画面全体をスクロールするよう
//リストビューからスクロール削除私のxmlは、私は、このアプリケーションを開いたときに、それは、リストビューからスクロール削除し、全体を追加
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/header"
android:orientation="horizontal"
android:layout_alignLeft="@+id/body"
android:layout_marginBottom="80dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
<LinearLayout
android:id="@+id/body"
android:orientation="vertical"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="@+id/header"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:paddingTop="10dp"
>
<ScrollView
android:layout_width="match_parent"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:weightSum="2"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:text="RSHO Doses"
android:layout_weight="1"
android:textColor="#636363"
android:textSize="@dimen/sub_Heading_Size"
android:drawablePadding="10dp"
android:drawableLeft="@drawable/rsho_drawable"
android:layout_height="wrap_content" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:textSize="@dimen/sub_Heading_Size"
android:text="Seizures"
android:drawablePadding="10dp"
android:drawableLeft="@drawable/seizures_drawable"
android:textColor="#636363"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:text="Events"
android:padding="@dimen/activity_horizontal_margin"
android:background="@color/colorHeadingBG"
android:textSize="@dimen/sub_Heading_Size"
android:textColor="@color/colorHeading"
android:layout_height="wrap_content" />
<ListView
android:layout_width="match_parent"
android:dividerHeight="2dp"
android:divider="#e5e5e5"
android:layout_alignParentTop="true"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_horizontal_margin"
android:id="@+id/listView"
android:layout_height="wrap_content"></ListView>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
ですページのリストビューの高さですが、常に下から開きます。このための解決策
あなたが欲しいのは混乱の種ですが、いくつかのカンマを置いてみたり、よく説明してみてください。 –
私は上記のコードを使用してlistviewだけでなく、それを行うことができますが、私はscrollwholeページをしたいですが、私はアプリケーションの画面の下から開きます。私のポイントを取得? –