I'm trying to use a GridLayout in my AXML file. In the Visual Studio 2015 designer it shows up perfectly. When I run the application in the Xamarin Android Player, Nexus 5 (Lollipop), the entire layout is blank. The title is displayed, so I know this activity is being started. I can hit breakpoints in the OnCreate
method too.
I'm using Xamarin.Android 6.0.
What am I doing wrong?
<?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="fill" android:layout_height="match_parent" android:layout_width="match_parent" android:columnCount="1" android:rowCount="3"> <TextView android:id="@+id/scoreboard_team_1_name" android:background="@color/team1" android:gravity="fill" android:layout_height="0dp" android:layout_rowWeight="1" android:layout_width="match_parent" android:text="@string/team_1_name_placeholder" /> <LinearLayout android:id="@+id/scoreboard_matches_layout" android:gravity="fill" android:layout_height="0dp" android:layout_rowWeight="4" android:layout_width="match_parent"/> <TextView android:id="@+id/scoreboard_team_2_name" android:background="@color/team2" android:gravity="fill" android:layout_height="0dp" android:layout_rowWeight="1" android:layout_width="match_parent" android:text="@string/team_2_name_placeholder" /> </GridLayout>
using Android.App; using Android.Content; using Android.Graphics; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using System; namespace TableTennis.Droid { [Activity] public class ScoreboardActivity : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Title = "Scoreboard"; SetContentView(Resource.Layout.Scoreboard); } } }
Answers
Height is 0 on your grid items.
Yes, as I understand, that is how you ensure the layout_rowWeight is respected. The GridLayout assigns a proportionate height instead.
I'll try setting that to something higher and see if that makes a difference.