Created
June 15, 2015 08:54
-
-
Save IlyaEremin/e28d51cd1341607a1e69 to your computer and use it in GitHub Desktop.
webView with NestedScrollView height bug (on samsung s3 4.3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NewsDetailsFragment extends Fragment { | |
private String html = "<html><body>\\u003cp\\u003e\\u0026nbsp;\\u003c/p\\u003e\\r\\n\\r\\n\\u003cp\\u003eКоманда Александра Хацкевича уступила действующим чемпионам Европы с минимальным счетом 0:1. Единственный гол испанцы забили на 45-й минуте усилиями Давида Сильвы.\\u003c/p\\u003e\\r\\n\\r\\n\\u003cp\\u003eПолузащитник \\u0026laquo;Рубина\\u0026raquo; Сергей Кисляк вышел на поле в стартовом составе и был заменен на 78-й минуте встречи.\\u003c/p\\u003e\\r\\n\\r\\n\\u003cp\\u003eТакже накануне сборная России на \\u0026laquo;Открытие Арена\\u0026raquo; в Москве с таким же счетом проиграла сборной Австрии. Футболисты \\u0026laquo;Рубина\\u0026raquo; Сергей Рыжиков, Эльмир Набиуллин и Магомед Оздоев на поле так и не появились.\\u0026nbsp;\\u003c/p\\u003e\\r\\n\\r\\n\\u003cp style=\\\"text-align:right\\\"\\u003eФото:\\u0026nbsp;\\u003ca href=\\\"http://ru.uefa.com/uefaeuro/qualifiers/season=2016/matches/round=2000446/match=2013962/postmatch/photos/index.html\\\"\\u003euefa.com\\u003c/a\\u003e\\u003c/p\\u003e\\r\\n</body></html>"; | |
@Override | |
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
return inflater.inflate(R.layout.news_details, container, false); | |
} | |
@Override | |
public void onViewCreated(View view, Bundle savedInstanceState) { | |
super.onViewCreated(view, savedInstanceState); | |
WebView content = (WebView) view.findViewById(R.id.content); | |
content.getSettings().setJavaScriptEnabled(true); | |
// for some reason xml definition of this doesn't work | |
content.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_INSET); | |
content.loadDataWithBaseURL(null, html, "text/html", "utf-8", null); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.design.widget.CoordinatorLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
xmlns:fresco="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<android.support.v4.widget.NestedScrollView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:layout_behavior="@string/appbar_scrolling_view_behavior" | |
> | |
<FrameLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:minHeight="500dp" | |
> | |
<WebView | |
android:id="@+id/content" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
/> | |
</FrameLayout> | |
</android.support.v4.widget.NestedScrollView> | |
<android.support.design.widget.AppBarLayout | |
android:layout_width="match_parent" | |
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" | |
android:layout_height="wrap_content"> | |
<android.support.design.widget.CollapsingToolbarLayout | |
android:id="@+id/collapsing_toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:contentScrim="?attr/colorPrimary" | |
app:layout_scrollFlags="scroll|exitUntilCollapsed"> | |
<RelativeLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
app:layout_collapseMode="parallax" | |
app:layout_collapseParallaxMultiplier="0.7"> | |
<com.facebook.drawee.view.SimpleDraweeView | |
android:id="@+id/image" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
fresco:placeholderImage="@drawable/news_placeholder" | |
/> | |
<View | |
android:layout_width="match_parent" | |
android:layout_height="200dp"/> | |
<TextView | |
android:id="@+id/date" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:textColor="@android:color/white" | |
android:layout_marginLeft="16dp" | |
android:layout_marginStart="16dp" | |
android:layout_alignParentLeft="true" | |
android:layout_alignParentStart="true" | |
android:layout_marginTop="64dp" | |
tools:text="17 августа" | |
/> | |
<TextView | |
android:id="@+id/title" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:textAppearance="?android:attr/textAppearanceLarge" | |
android:textStyle="bold" | |
android:textColor="@android:color/white" | |
android:layout_marginTop="8dp" | |
android:layout_below="@+id/date" | |
android:layout_alignLeft="@+id/date" | |
android:layout_alignStart="@+id/date" | |
tools:text="Открытие для стадиона Казань-Арена" | |
/> | |
</RelativeLayout> | |
<android.support.v7.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" | |
app:layout_collapseMode="pin" | |
/> | |
</android.support.design.widget.CollapsingToolbarLayout> | |
</android.support.design.widget.AppBarLayout> | |
</android.support.design.widget.CoordinatorLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment