为什么WebView滚动条呈现为黑色矩形?就好像没有加载底层滚动条图形而整个滚动条区域最终变成黑色。我正在加载静态HTML。这是它的样子:
以下是我认为应该是这样的:
这是XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<WebView
android:id="@+id/initial_webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
这是MainActivity:
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String html = "";
for(int i=0; i<250; i++) {
html += "text"+i+" ";
}
WebView wv = (WebView)findViewById(R.id.initial_webview);
wv.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
我正在使用SDK 21和minSDK 16,以及带有API 17的Samsung Galaxy S3配置文件,如果有帮助的话。