【发布时间】:2012-09-18 13:41:23
【问题描述】:
我正在尝试在框架布局中使用滚动视图。 滚动视图应显示在显示屏的下半部分。
目前定位正确:
http://www.gtv-handball.de/Unbenannt.png
如您所见,正确的区域是否可缩放。 但问题是,上半部分不能再点击了,因为滚动视图在这部分上面。
为了在下半部分显示滚动视图,我在上面加了一些填充:
scrollviwe = (ScrollView)findViewById(R.id.linlayout);
scrollview.setPadding(0, 175, 0, 0);
所以我没有找到任何方法来使用填充选项显示它。
我认为,没有办法绕过为滚动视图设置边距, 但是我该怎么做呢?
这里是完整但缩短的 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/framelayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|left" >
<ImageView
android:id="@+id/coverimg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:maxHeight="100dp"
android:minHeight="130dp"
android:minWidth="130dp"
android:src="@drawable/cover_img" />
</FrameLayout>
<ScrollView
android:id="@+id/linlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/linlayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/teilen"
style="ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_blue"
android:gravity="center_vertical|center_horizontal"
android:padding="4dp"
android:text="Teilen"
android:layout_margin="4dp"
android:layout_weight="1" />
<Button
android:id="@+id/kaufen"
style="ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_blue"
android:gravity="center_vertical|center_horizontal"
android:padding="4dp"
android:text="Kaufen"
android:layout_margin="4dp"
android:layout_weight="1"/>
<Button
android:id="@+id/youtube"
style="ButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_blue"
android:gravity="center_vertical|center_horizontal"
android:padding="4dp"
android:text="YouTube"
android:layout_margin="4dp"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Zuletzt gehört:" />
</LinearLayout>
</ScrollView>
</FrameLayout>
【问题讨论】:
-
如果你把滚动视图放在另一个框架布局的顶部,它肯定不会起作用。使用线性布局(垂直)并将每个高度为 0dp,重量为 1
-
我应该把线性布局放在哪里?在第一个框架布局之后和滚动视图之前?
-
而不是第一个框架布局
-
那么我无法管理重叠的某些视图。
-
没有意识到它们是重叠的。使用相对布局,然后
标签: java android layout scrollview android-framelayout