ScrollView无效。我尝试了不同的组合而没有运气。有人能指出我哪里出错了吗?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#333333"
android:orientation="horizontal" >
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_launcher" />
<com.appsolute.ultimateproject.TypedfacedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
android:id="@+id/overview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff"
font:typeface="Roboto-Condensed.ttf" />
</LinearLayout>
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:paddingLeft="@dimen/list_padding"
android:paddingRight="@dimen/list_padding" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#333333"
android:orientation="horizontal"
android:paddingTop="10dp" >
<com.appsolute.ultimateproject.TypedfacedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:paddingBottom="2dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#ffffff"
font:typeface="Roboto-Condensed.ttf" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp" >
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_action_person" />
<com.appsolute.ultimateproject.TypedfacedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
font:typeface="Roboto-Condensed.ttf" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#333333"
android:padding="1dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="1dp" >
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_action_fav" />
<com.appsolute.ultimateproject.TypedfacedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
android:id="@+id/favorites"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
font:typeface="Roboto-Condensed.ttf" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#333333"
android:padding="1dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="1dp" >
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_action_save" />
<com.appsolute.ultimateproject.TypedfacedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:font="http://schemas.android.com/apk/res/com.appsolute.ultimateproject"
android:id="@+id/saved"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
font:typeface="Roboto-Condensed.ttf" />
</LinearLayout>
</LinearLayout>
</ScrollView>
我使用了fillViewport并且还使基础内容包装。请帮忙。
答案 0 :(得分:1)
Per 'How can I put a ListView
in a ScrollView
'? question以及随后的回答,ListView
处理他们自己的内部滚动,它既昂贵(从布局性能的角度来看),也不能将一个滚动容器放在另一个滚动容器中。
解决此问题的最简单方法是使用ListView.addHeaderView和ListView.addFooterView,如果您希望布局中的其他项目与ListView
一起滚动。
答案 1 :(得分:0)
永远不要将ListView放在ScrollView中! Google提供了“Scrollview中的android ListView”以获取更多信息。一个例子就是这个:How can I put a ListView into a ScrollView without it collapsing?