我在滚动视图中有3个视图,我想将其分布在整个scoll布局中。我不能让它正常工作,希望有人能看到这个问题。
我想要的是在滚动视图中:
<scrollview>
<linear or relative view?>
(filler)
moneywheels
(filler)
timewheels
timeWheelsText
(filler)
</linear or relative view?>
</scrollview>非常感谢您的帮助!
<ScrollView
android:id="@+id/ScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical"
android:weightSum="3" >
<LinearLayout
android:id="@+id/fil1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/moneyWheels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0">
<!-- content -->
</LinearLayout>
<LinearLayout
android:id="@+id/fill2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:id="@+id/timeWheels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@drawable/time"
android:padding="@dimen/padding" >
<!-- content -->
</LinearLayout>
<LinearLayout
android:id="@+id/timeWheelsText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="0"
android:gravity="top|center" >
<!-- content -->
</LinearLayout>
<LinearLayout
android:id="@+id/fill3"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</ScrollView>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="bottom|center_horizontal"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxxx"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
</LinearLayout>
发布于 2012-07-28 23:23:27
您的布局XML文件无效。在处理XML时,您应该始终只有一个顶级标记。假设你想让广告显示在滚动视图的下方,你想要的东西如下:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="bottom|center_horizontal"
android:orientation="vertical" >
<ScrollView ...>
<!-- Other pieces under scrollview go here -->
</ScrollView>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxxx"
ads:loadAdOnCreate="true"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
</LinearLayout>此外,对于您的间隔,我建议只使用视图,而不是LinearLayouts。视图将是一个更轻量级的类,并且不会使用那么多资源。使用LinearLayouts作为间隔可能还会引起其他意外。
https://stackoverflow.com/questions/11702096
复制相似问题