【问题标题】:Best way to create a header and footer for webview in Android在 Android 中为 webview 创建页眉和页脚的最佳方法
【发布时间】:2015-01-31 15:09:44
【问题描述】:
我想创建新闻,例如在顶部开头有标题和日期以及一些分享和收藏按钮的活动,文章文本(可能还有一些图像和标题标题)是我从服务器获取的 html,并且最后是相关新闻列表!
文章 html 我必须使用 WebView,但由于我需要标题和主 webview 一起滚动,我可能不得不在包装 ScrollView 中使用它们,这显然不是最好的选择!
我有红色这些:
webview in scrollview 和
Disable scrolling in webview
但我想知道截至 2015 年实现这一目标的最佳方式是什么!可以与android 4.01+一起使用
【问题讨论】:
标签:
android
android-webview
android-4.0-ice-cream-sandwich
android-scrollview
【解决方案1】:
好吧,事实证明,最好的办法就是把它们放在一个滚动视图中!
它适用于我的三星 android 4.4,但我不知道其余的!
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/news_activity_title_lay"
android:layout_width="match_parent"
android:layout_height="wrap_content">
//Some Widgets Here for header
</RelativeLayout>
<WebView
android:layout_below="@+id/news_activity_title_lay"
android:id="@+id/news_activity_web_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
</WebView>
<LinearLayout
android:id="@+id/news_activity_related_base_lay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/news_activity_web_view">
//Some Widgets Here foe footer
</LinearLayout>
</RelativeLayout>
有趣的是,Android Studio 说我不应该这样做! :/