Want to design a FrameLayout, which has a WebView, the top WebView folded a transparent LinearLayout (id is middleLayout), while in the case of no network will LinearLayout becomes opaque, blocking the WebView, the user is prompted not networking.
Layout as follows:
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: orientation = "vertical">android: id = "@ + id / detailWebView"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: layout_marginTop = "48dip" />android: id = "@ + id / middleLayout"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: layout_marginTop = "48dip"
android: background = "# 00000000"
android: orientation = "vertical" />android: layout_width = "fill_parent"
android: layout_height = "48dip"
android: layout_gravity = "top"
android: background = "@ drawable / title_bg"
android: orientation = "horizontal">android: id = "@ + id / back"
android: layout_width = "48dip"
android: layout_height = "fill_parent"
android: background = "# 00000000"
android: scaleType = "fitCenter"
android: src = "@ drawable / back" />
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: background = "# 00000000"
android: orientation = "vertical" />
Triggered when there is no network callQuestion background function:
private void callQuestion (String result) {
if (result == "No result") {
LinearLayout middleLayout = (LinearLayout) findViewById (R.id.middleLayout);
middleLayout.setBackgroundColor (Color.WHITE);
View view = LayoutInflater.from (this). Inflate (
R.layout.detail_no_result, null);
middleLayout.addView (view);
}
}
Among R.layout.detail_no_result follows:
android: id = "@ + id/txt1"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: background = "# ff0"
android: gravity = "center"
android: text = "Network problem, I refresh ..."
android: textSize = "30sp" />
Why not fill the TextView (fill_parent) throughout middleLayout? ? ?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
LinearLayout.LayoutParams ly = new LayoutParams (LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
middleLayout.addView (view, ly);
No comments:
Post a Comment