我使用webview以“对齐”对齐方式显示文本。我的问题是,当我测试应用程序时,webview显示在活动的底部。这是xml文件的内容。在哪里,我把它放在公司网站和支持链接之间。基本上我需要在“公司简介”之后展示它......我怎么能这样做??
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/infoll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="InfoContent"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Company Website : "
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/company_website"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="example link"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#0000FF" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Company Profile : "
android:textAppearance="?android:attr/textAppearanceMedium" />
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Support link for app : "
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/support_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="example link"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#0000FF" />
</LinearLayout>
</LinearLayout>
这是我以编程方式将数据加载到webview中的方式。 infoActivity.java
`setContentView(R.layout.layout_info);
WebView view = new WebView(this);
view.setVerticalScrollBarEnabled(false);
((LinearLayout)findViewById(R.id.infoll)).addView(view);
view.loadData(getString(R.string.info), "text/html", "utf-8");`
这是我加载到网页视图中的字符串 的strings.xml
`<string name="info">
<![CDATA[
<html>
<head></head>
<body style="text-align:justify;color:gray;background-color:white;">
Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content Dummy content.
</body>
</html>
]]></string>`
可能是因为以编程方式将数据加载到webview中......? 提前致谢
This is what i am getting right now(SCREENSHOT 1)
This is what i am getting when i added layout_height=100dp for the webview(SCREENSHOT 2) 基本上我希望我的webview在那个空白区域
答案 0 :(得分:0)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Company Profile : "
android:textAppearance="?android:attr/textAppearanceMedium" />
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
机器人:layout_height =&#34; WRAP_CONTENT&#34; 对于作为webview父母的LinearLayout,你无法看到webview。
给下面的线性布局赋予一些权重,然后再试一次。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Company Profile : "
android:textAppearance="?android:attr/textAppearanceMedium" />
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
答案 1 :(得分:0)
`的setContentView(R.layout.layout_info);
错误: WebView视图=新的WebView(this); view.setVerticalScrollBarEnabled(假);
//void rpProducts(object sender, RepeaterItemEventArgs e)
//{
// Label l = (Label)e.Item.FindControl("Label1");
// string s = l.Text;
//}
//protected void add_Click(object sender, RepeaterCommandEventArgs e)
//{
// Label l = (Label)e.Item.FindControl("Label1");
// string s = l.Text;
//}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
Label l = (Label)e.Item.FindControl("Label1");
string s = l.Text;
}
protected void Button1_Click(object sender, EventArgs e)
{
}
对: WebView视图= findViewById(R.id.webview);
((LinearLayout)findViewById(R.id.infoll)).addView(view);