我有一个布局,带有一些按钮在底部的文本视图。 textview设置为展开以填充空间。这可以。但是,当我将textview更改为webview时,webview不会扩展以填充空间。怎么了?TextView扩展布局,但webview不
这是工作的罚款:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<!-- height set to fill because background is black and we want
the light background -->
<TextView
style="@style/subtopicView"
android:id="@+id/subtopic_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</ScrollView>
<include layout="@layout/include_html_view_footer" />
</LinearLayout>
这不是,但唯一不变的是对TextView的网页视图和所有其他值保持不变。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
<!-- height set to fill because background is black and we want
the light background -->
<WebView
style="@style/subtopicView"
android:id="@+id/subtopic_content"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</ScrollView>
<include layout="@layout/include_html_view_footer" />
</LinearLayout>
的包括很简单:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/tintedColour"
android:orientation="horizontal"
android:paddingBottom="@dimen/spacer"
android:paddingTop="@dimen/spacer" >
<Button
android:id="@+id/PrevPage"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/previous" />
<Button
android:id="@+id/NextPage"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/next" />
<Button
android:id="@+id/Copy"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/copyclipboard" />
</LinearLayout>
感谢您的帮助。
谢谢,抱歉,我忘了+1这个。我想我假设,因为我需要在textview周围使用滚动条布局,我必须对webview执行相同的操作。另外使用fillviewport意味着我可以删除有关使用fill_parent的警告并使用wrap_content :) –