我有一个的LinearLayout
在滚动型
,有安卓layout_height =FILL_PARENT
,但它并没有扩展到滚动型
的整个高度。我的布局看起来是这样的:
I have a LinearLayout
inside a ScrollView
that has android:layout_height="fill_parent"
, but it doesn't expand to the full height of the ScrollView
. My layout looks something like:
level layout layout_width layout_height
1 LinearLayout fill_parent fill_parent
2 LinearLayout fill_parent wrap_content
3 (some irrelevant stuff)
2 ScrollView fill_parent fill_parent <-- this expands full height
3 LinearLayout fill_parent fill_parent <-- this does not (has orientation=vertical)
(following stuff probably are irrelevant, but just to be sure:)
4 TextView fill_parent fill_parent
4 LinearLayout fill_parent wrap_content
我可以看到的LinearLayout
不展开的全高的滚动型
因为Eclipse在 Android的布局编辑器
,如果我选择了滚动型
(在大纲面板),它是用红色边框突出,填补了屏幕的底部,但是当我选择的LinearLayout
其亮点并不扩展到屏幕的底部。我怎样才能得到它这样做?
I can see that the LinearLayout
doesn't expand the full height of the ScrollView
because in Eclipse in Android Layout Editor
, if I select the ScrollView
(in the Outline panel) it is highlighted with a red border that fills the screen to the bottom but when I select the LinearLayout
its highlight doesn't expand to the bottom of the screen. How can I get it to do so?
我想达到的效果是有一些文本和它下面的按钮(在的LinearLayout
4级有只是一个按钮)。该文本可以是大到需要一个滚动条,在这种情况下,我希望用户有才能看到该按钮向下滚动。 ,我想的LinearLayout
包含按钮粘到屏幕的底部。
The effect I'm trying to achieve is to have some text and a button below it (inside the LinearLayout
in level 4 there's just a button). The text can be big enough to need a scrollbar, in which case I want the user to have to scroll down in order to see the button. In case the text is not big enough for a scroll bar, I want the LinearLayout
containing the button to stick to the bottom of the screen.
起初我还以为我不应该张贴完整的XML,因为它通常是一个回合下来看到一个问题code一大块。然而,现在看来,这可能是必要的,所以这里的完整布局。
At first I thought I shouldn't post the full XML because it's usually a turn-down to see a huge chunk of code in a question. However, it seems it might be necessary, so here's the full layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/video_layout"
android:focusable="true"
style="@style/VideoLayout">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="@android:drawable/ic_media_play"
android:foregroundGravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/video_thumb"
android:padding="5dip"
android:background="#454545"/>
</FrameLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
style="@style/VideoTitle"
android:id="@+id/video_title"
android:layout_gravity="center"
android:layout_weight="1"/>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<!-- this ScrollView expands the full height of the screen.
However, the next LinearLayout does not expand the full height of the ScrollView -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_gravity="fill"
android:orientation="vertical"
android:id="@+id/info_layout">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/info_body"
style="@style/InfoText"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
style="@android:style/ButtonBar">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="@string/button_readmore"
android:id="@+id/btn_read_more"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
目前,我已经使出安卓layout_gravity =底部
上的问题的LinearLayout
,这使按钮粘在屏幕的底部不管。但是,这也使得文本粘在屏幕的底部,这不正是我后。
At the moment I have resorted to android:layout_gravity="bottom"
on the problematic LinearLayout
, which makes the button stick to the bottom of the screen no matter what. But that also makes the text stick to the bottom of the screen, which is not exactly what I was after.
更新:刮的是,安卓layout_gravity =底部
使滚动型
无力,好,滚动。其他的想法?
Update: scratch that, android:layout_gravity="bottom"
makes the ScrollView
unable to, well, scroll. Other ideas?
找到了解决自己到底。问题是不与的LinearLayout
,而在滚动型
(似乎不可思议,考虑到一个事实,即滚动型
是扩张,而的LinearLayout
不是)。
Found the solution myself in the end. The problem was not with the LinearLayout
, but with the ScrollView
(seems weird, considering the fact that the ScrollView
was expanding, while the LinearLayout
wasn't).
的解决方案是使用机器人:fillViewport =真正的
在滚动型
The solution was to use android:fillViewport="true"
on the ScrollView
.