0

我正处于我要松开它的地步。

问题:我将GraphInWebView膨胀到名为 formDialog(其他文件)的布局中 formDialog.AddView(LayoutInflater.Inflate(Resource.Layout.GraphInWebview, null));

仅此一项就完美了,但是一旦我尝试将LineItem膨胀到GraphInWebView@+id/SideWidget中,后者就永远不会显示。

我检查了源代码 - LineItem视图已膨胀,但并未嵌套在 SideWidget 中

我有以下 xml 文件。

GraphInWebview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
  <WebView
      android:id="@+id/graphView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="#00FF00"/>
  <LinearLayout
        android:id="@+id/SideWidget"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#0000FF">
  </LinearLayout>
</LinearLayout>

lineItem.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">
  <RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content">
    <ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/Icon"
      android:maxHeight="5dp"
      android:maxWidth="5dp"
      android:id="@+id/icon"
      android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"/>
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Appointment: Appointment with Spur Cresta"
      android:id="@+id/appointmentTitle"
      android:minWidth="60dp"
      android:layout_alignParentBottom="true"
      android:layout_toRightOf="@+id/icon"/>
  </RelativeLayout>
  <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Appointment: Appointment with Spur Cresta"
    android:id="@+id/appointmentText"
    android:minWidth="60dp"/>
</LinearLayout>

C#

        //First inflate views to be injected into the default action bar
        formDialog.AddView(LayoutInflater.Inflate(Resource.Layout.googleGraphInWebview, null));

        manageScheduleButton = (Button)FindViewById(Resource.Id.ManageButton);
        locationalServicesButton = (Button)FindViewById(Resource.Id.LocationalServicesButton);
        myProfileButton = (Button)FindViewById(Resource.Id.MyProfileButton);
        myClientsButton = (Button)FindViewById(Resource.Id.MyClientsButton);

        manageScheduleButton.Click += ManageScheduleMenuClick;
        locationalServicesButton.Click += locationalServicesButtonClick;
        myProfileButton.Click += myProfileButtonClick;
        myClientsButton.Click += myClientsButtonClick;

        formDialog.SetMinimumHeight(400);

        WebView graph = FindViewById<WebView>(Resource.Id.graphView);
        LinearLayout sideWidget = FindViewById<LinearLayout>(Resource.Id.SideWidget);
        sideWidget.AddView(LayoutInflater.Inflate(Resource.Layout.LineItem, null));

        graph.Settings.JavaScriptEnabled = true;
        graph.SetWebViewClient(new webView(formDialog));
        graph.LoadUrl("file:///android_asset/graph.html");

任何人都可以建议解决这个问题的方法吗?

问候

一种

4

1 回答 1

0

我想通了....机器人layout_weight是关键...

Given a view where two layouts both request, for example, fill_parent, the, for example, wanting them to share the view 40 - 60 you would assign to one layout_weight=4 and to the other layout_weight=6

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
  <WebView
      android:id="@+id/graphView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="#00FF00"/>
  <LinearLayout
        android:id="@+id/SideWidget"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#0000FF">
  </LinearLayout>
</LinearLayout>

I post the finished code

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
      <WebView
          android:id="@+id/graphView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_wight="2"
            android:background="#00FF00"/>
      <LinearLayout
        android:id="@+id/SideWidget"
        android:orientation="vertical"
        android:layout_wight="1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#0000FF">
  </LinearLayout>
</LinearLayout>
于 2013-03-13T20:30:50.383 回答