我在一個相對佈局中使用MvxBindableGridView,它工作的很完美。然後我意識到我需要使用LinearLayouts來使屏幕在不同設備上正確縮放。當我改變到的LinearLayout和運行應用程序在GridView是空的,調試輸出顯示了一些綁定錯誤MvxBindableGridView在一個線性佈局沒有綁定到任何項目
12-03 16:55:38.363 I/MvxBind (2689): 14.25 Failed to create target binding for from ClickCommand to ClickItemSquare
MvxBind:Warning: 14.25 Failed to create target binding for from ClickCommand to ClickItemSquare
12-03 16:55:38.363 I/mono-stdout(2689): MvxBind:Warning: 14.25 Failed to create target binding for from ClickCommand to ClickItemSquare
有誰知道爲什麼失敗時,它完全在RelativeLayout的?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/xxxxx"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/layoutresults"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textscore"
local:MvxBind="{'Text':{'Path':'Score'}}"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="0000"
android:textColor="#ff60350f"
android:textSize="20dp"
android:layout_x="25dp"
android:layout_y="45dp"
android:textStyle="bold"
android:gravity="center"
android:layout_marginTop="53dp"
android:layout_marginLeft="25dp" />
<TextView
android:id="@+id/layoutstartnewgame"
android:layout_width="100dp"
android:layout_height="65dp"
android:layout_x="109dp"
android:layout_y="23dp"
android:textStyle="bold"
local:MvxBind="{'Click':{'Path':'StartNewGame'}}"
android:layout_centerHorizontal="true"
android:layout_marginTop="27dp" />
<TextView
android:id="@+id/texttime"
local:MvxBind="{'Text':{'Path':'Time'}}"
android:text="00:00"
android:textColor="#ff60350f"
android:textSize="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="245dp"
android:layout_y="45dp"
android:textStyle="bold"
android:layout_marginTop="53dp"
android:layout_alignParentRight="true"
android:layout_marginRight="23dp" />
</RelativeLayout>
<cirrious.mvvmcross.binding.android.views.MvxBindableGridView
android:layout_below="@+id/layoutresults"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numColumns="4"
android:gravity="center"
android:listSelector="#00000000"
local:MvxItemTemplate="@layout/itemimage"
local:MvxBind="{'ItemsSource':{'Path':'Squares'}, 'ClickItemSquare':{'Path':'ClickCommand'}}"
android:layout_marginTop="8dp" />
</RelativeLayout>
改爲線性
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/xxxxx"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/TabletGameScreen">
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_weight=".1"
android:gravity="center" />
<LinearLayout
android:id="@+id/layoutresults"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".1">
<TextView
android:id="@+id/textscore"
local:MvxBind="{'Text':{'Path':'Score'}}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="0000"
android:textColor="#ff60350f"
android:textSize="20dp"
android:textStyle="bold"
android:gravity="center_horizontal"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:textStyle="bold"
local:MvxBind="{'Click':{'Path':'StartNewGame'}}"
android:layout_centerHorizontal="true"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/texttime"
local:MvxBind="{'Text':{'Path':'Time'}}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="00:00"
android:textColor="#ff60350f"
android:textSize="20dp"
android:textStyle="bold"
android:layout_gravity="center_vertical"
android:gravity="center_horizontal" />
</LinearLayout>
<cirrious.mvvmcross.binding.android.views.MvxBindableGridView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight=".8"
android:numColumns="4"
android:gravity="center"
android:listSelector="#00000000"
local:MvxItemTemplate="@layout/itemimage"
local:MvxBind="{'ItemsSource':{'Path':'Squares'}, 'ClickItemSquare':{'Path':'ClickCommand'}}" />
</LinearLayout>
你能提供比這更多的代碼嗎?例如。準確的前後都做了什麼和沒有工作? – Stuart