视图布局未按预期显示
本文关键字:显示 布局 视图 | 更新日期: 2023-09-27 18:03:58
我马上就要失去它了
问题:我膨胀GraphInWebView到布局称为formDialog(一些其他文件)formDialog.AddView(LayoutInflater.Inflate(Resource.Layout.GraphInWebview, null));
单独这工作完美,但一旦我试图膨胀LineItem到GraphInWebView's @+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");
谁能提出一个解决这个问题的方法?对
我算出来了....机器人的layout_weight
是关键…
给定一个视图,其中两个布局都请求,例如,fill_parent
,例如,希望它们共享视图40 - 60,您将分配给一个layout_weight=4
和另一个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>
我发布了完成的代码
<?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>