我试图在linearlayout中滚动一些内容,外部布局是包含标题和底部菜单的relativelayout。
如何使其可滚动?
这是我目前的布局。但是在滚动linearlayout部分时没有任何反应。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<include layout="@layout/header_guide"
android:id="@+id/GuideHeaderInclude"
android:layout_alignParentTop="true"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/GuideHeaderInclude"
android:isScrollContainer="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/GuideContentHolder">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/guidecard"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideRegCardHeader"
android:layout_gravity="center_horizontal"
style="@style/OnlineAboutHeaderStyle"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideRegCardText"
style="@style/OnlineAboutTextStyle"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/guidemap"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideMapHeader"
android:layout_gravity="center_horizontal"
style="@style/OnlineAboutHeaderStyle"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideMapText"
style="@style/OnlineAboutTextStyle"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/guidelist"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideVerifyHeader"
android:layout_gravity="center_horizontal"
style="@style/OnlineAboutHeaderStyle"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideVerifyText"
style="@style/OnlineAboutTextStyle"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/guidecashback"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideCashbackHeader"
android:layout_gravity="center_horizontal"
style="@style/OnlineAboutHeaderStyle"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideCashbackText"
style="@style/OnlineAboutTextStyle"
/>
</LinearLayout>
</ScrollView>
<include layout="@layout/bottom_menu"
android:id="@+id/GuideBottomMenu"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
答案 0 :(得分:3)
请尝试这种方式,希望这有助于您解决问题。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<include layout="@layout/header_guide"
android:id="@+id/GuideHeaderInclude"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:isScrollContainer="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/GuideContentHolder">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/guidecard"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideRegCardHeader"
android:layout_gravity="center_horizontal"
style="@style/OnlineAboutHeaderStyle"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideRegCardText"
style="@style/OnlineAboutTextStyle"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/guidemap"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideMapHeader"
android:layout_gravity="center_horizontal"
style="@style/OnlineAboutHeaderStyle"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideMapText"
style="@style/OnlineAboutTextStyle"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/guidelist"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideVerifyHeader"
android:layout_gravity="center_horizontal"
style="@style/OnlineAboutHeaderStyle"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideVerifyText"
style="@style/OnlineAboutTextStyle"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/guidecashback"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideCashbackHeader"
android:layout_gravity="center_horizontal"
style="@style/OnlineAboutHeaderStyle"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/GuideCashbackText"
style="@style/OnlineAboutTextStyle"/>
</LinearLayout>
</ScrollView>
<include layout="@layout/bottom_menu"
android:id="@+id/GuideBottomMenu"/>
</LinearLayout>