弹出 window 未按预期显示 (Android / Xamarin)
Popup window not showing as expected (Android / Xamarin)
大家下午好!
我在 listView 弹出窗口中遇到了一些问题。
单击任何列表元素时,将出现一个弹出窗口并显示游戏的所有信息(它是 TicTacToe 游戏历史)。我已经完成了模式的布局,并且在预览中显示了我想要的。
但是当我 运行 在我的 Android 中时,一些元素是 "cut" as shown here...
当前activity代码:
private void List_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
View popup = inflater.Inflate(Resource.Layout.DesenhoJogo, null); //DesenhoJogo is my Layout for the modal
PopupWindow janela = new PopupWindow(popup, ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, false);
janela.ShowAsDropDown(popup, Android.Views.ViewGroup.LayoutParams.WrapContent, Android.Views.ViewGroup.LayoutParams.WrapContent);
Button voltar = popup.FindViewById<Button>(Resource.Id.btnVoltar);
voltar.Click += (s, o) => { janela.Dismiss(); };
}
编辑:
布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:orientation="vertical"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="match_parent"
p1:layout_height="match_parent"
p1:id="@+id/linearLayout1"
p1:background="@drawable/fundoverde"
p1:weightSum="3">
<RelativeLayout
p1:layout_width="match_parent"
p1:layout_height="wrap_content"
p1:id="@+id/relativeLayout1"
p1:layout_marginLeft="5dp"
p1:layout_marginRight="5dp">
<ImageView
p1:src="@drawable/xbranco"
p1:layout_width="35dp"
p1:layout_height="35dp"
p1:layout_margin="5dp"
p1:id="@+id/xJogadorBranco" />
<ImageView
p1:src="@drawable/obranco"
p1:layout_width="35dp"
p1:layout_height="35dp"
p1:layout_margin="5dp"
p1:id="@+id/oJogadorBranco"
p1:layout_below="@id/xJogadorBranco" />
<TextView
p1:text="Jogador 1"
p1:layout_width="match_parent"
p1:layout_height="35dp"
p1:layout_toRightOf="@id/xJogadorBranco"
p1:id="@+id/nomeJogador1"
p1:layout_margin="5dp"
p1:gravity="fill"
p1:textSize="25dp" />
<TextView
p1:text="Jogador 2"
p1:layout_width="match_parent"
p1:layout_height="35dp"
p1:layout_toRightOf="@id/oJogadorBranco"
p1:id="@+id/nomeJogador2"
p1:layout_margin="5dp"
p1:gravity="fill"
p1:textSize="25dp"
p1:layout_below="@id/nomeJogador1" />
<TextView
p1:text="Jogadas: "
p1:layout_width="match_parent"
p1:layout_height="35dp"
p1:id="@+id/jogadas"
p1:gravity="center"
p1:textSize="25dp"
p1:layout_below="@+id/nomeJogador2"
p1:layout_marginBottom="5dp"
p1:layout_marginRight="5dp"
p1:layout_marginLeft="5dp" />
<TextView
p1:text="Vencedor: "
p1:layout_width="match_parent"
p1:layout_height="35dp"
p1:id="@+id/vencedor"
p1:gravity="center"
p1:textSize="25dp"
p1:layout_below="@+id/jogadas"
p1:padding="5dp"
p1:layout_marginBottom="5dp"
p1:layout_marginLeft="5dp"
p1:layout_marginRight="5dp" />
</RelativeLayout>
<LinearLayout
p1:layout_width="match_parent"
p1:layout_height="wrap_content"
p1:orientation="vertical"
p1:weightSum="3"
p1:background="@drawable/velha"
p1:layout_weight="3"
p1:id="@+id/linearLayout5"
p1:layout_marginBottom="10dp"
p1:layout_marginLeft="5dp"
p1:layout_marginRight="5dp"
p1:layout_marginTop="5dp">
<LinearLayout
p1:layout_width="match_parent"
p1:layout_height="0dp"
p1:layout_weight="1"
p1:orientation="horizontal"
p1:weightSum="3"
p1:id="@+id/linearLayout2">
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos00"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos01"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos02"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
</LinearLayout>
<LinearLayout
p1:layout_width="match_parent"
p1:layout_height="0dp"
p1:layout_weight="1"
p1:orientation="horizontal"
p1:weightSum="3"
p1:id="@+id/linearLayout3">
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos10"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos11"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos12"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
</LinearLayout>
<LinearLayout
p1:layout_width="match_parent"
p1:layout_height="0dp"
p1:layout_weight="1"
p1:orientation="horizontal"
p1:weightSum="3"
p1:id="@+id/linearLayout4">
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos20"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos21"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos22"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
</LinearLayout>
</LinearLayout>
<Button
p1:text="Voltar"
p1:layout_width="match_parent"
p1:layout_height="wrap_content"
p1:id="@+id/btnVoltar"
p1:layout_gravity="bottom"
p1:textSize="20dp"
p1:layout_marginLeft="5dp"
p1:layout_marginRight="5dp"
p1:layout_weight="0" />
</LinearLayout>
有什么办法解决吗?
PS:两周前开始使用 Xamarin,所以对我来说一些编码理解有点困难 =/
谢谢!
编辑 -解决方案:
我遵循了 jzeferino 的提示,并进行了更多研究。即使在他的提示之后,布局仍然不是它应该的样子。所以我意识到问题出在状态栏高度上。在更改布局中的一些小问题后,我所要做的就是创建一个方法来获取 return 它的高度
public int getStatusBarHeight()
{
int statusBarHeight = 0;
int resourceId = Resources.GetIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0)
{
statusBarHeight = Resources.GetDimensionPixelSize(resourceId);
}
return statusBarHeight;
}
为了在后面的行janela.ShowAsDropDown(popup, Android.Views.ViewGroup.LayoutParams.MatchParent, tam);
中作为参数使用,其中int tam = getStatusBarHeight();
而最后的结果是this one
我需要改变一些东西。
尽量不要在 layout_height 和 layout_width 上使用那么多固定维度。
您使用的权重不正确。我删除了它。
最终代码(注意我需要更改资源名称):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<ImageView
android:id="@+id/xJogadorBranco"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_margin="5dp"
android:src="@drawable/icno" />
<ImageView
android:id="@+id/oJogadorBranco"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_below="@id/xJogadorBranco"
android:layout_margin="5dp"
android:src="@drawable/icno" />
<TextView
android:id="@+id/nomeJogador1"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_margin="5dp"
android:layout_toRightOf="@id/xJogadorBranco"
android:gravity="fill"
android:text="Jogador 1"
android:textSize="25dp" />
<TextView
android:id="@+id/nomeJogador2"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_below="@id/nomeJogador1"
android:layout_margin="5dp"
android:layout_toRightOf="@id/oJogadorBranco"
android:gravity="fill"
android:text="Jogador 2"
android:textSize="25dp" />
<TextView
android:id="@+id/jogadas"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/nomeJogador2"
android:layout_margin="3dp"
android:gravity="center"
android:text="Jogadas: "
android:textSize="25dp" />
<TextView
android:id="@+id/vencedor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/jogadas"
android:layout_margin="3dp"
android:gravity="center"
android:text="Vencedor: "
android:textSize="25dp" />
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/grid"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos00"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos01"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos02"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos10"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos11"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos12"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos20"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos21"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos22"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/btnVoltar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="Voltar"
android:textSize="20dp" />
</LinearLayout>
结果:
大家下午好!
我在 listView 弹出窗口中遇到了一些问题。
单击任何列表元素时,将出现一个弹出窗口并显示游戏的所有信息(它是 TicTacToe 游戏历史)。我已经完成了模式的布局,并且在预览中显示了我想要的。
但是当我 运行 在我的 Android 中时,一些元素是 "cut" as shown here...
当前activity代码:
private void List_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
View popup = inflater.Inflate(Resource.Layout.DesenhoJogo, null); //DesenhoJogo is my Layout for the modal
PopupWindow janela = new PopupWindow(popup, ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, false);
janela.ShowAsDropDown(popup, Android.Views.ViewGroup.LayoutParams.WrapContent, Android.Views.ViewGroup.LayoutParams.WrapContent);
Button voltar = popup.FindViewById<Button>(Resource.Id.btnVoltar);
voltar.Click += (s, o) => { janela.Dismiss(); };
}
编辑: 布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:orientation="vertical"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="match_parent"
p1:layout_height="match_parent"
p1:id="@+id/linearLayout1"
p1:background="@drawable/fundoverde"
p1:weightSum="3">
<RelativeLayout
p1:layout_width="match_parent"
p1:layout_height="wrap_content"
p1:id="@+id/relativeLayout1"
p1:layout_marginLeft="5dp"
p1:layout_marginRight="5dp">
<ImageView
p1:src="@drawable/xbranco"
p1:layout_width="35dp"
p1:layout_height="35dp"
p1:layout_margin="5dp"
p1:id="@+id/xJogadorBranco" />
<ImageView
p1:src="@drawable/obranco"
p1:layout_width="35dp"
p1:layout_height="35dp"
p1:layout_margin="5dp"
p1:id="@+id/oJogadorBranco"
p1:layout_below="@id/xJogadorBranco" />
<TextView
p1:text="Jogador 1"
p1:layout_width="match_parent"
p1:layout_height="35dp"
p1:layout_toRightOf="@id/xJogadorBranco"
p1:id="@+id/nomeJogador1"
p1:layout_margin="5dp"
p1:gravity="fill"
p1:textSize="25dp" />
<TextView
p1:text="Jogador 2"
p1:layout_width="match_parent"
p1:layout_height="35dp"
p1:layout_toRightOf="@id/oJogadorBranco"
p1:id="@+id/nomeJogador2"
p1:layout_margin="5dp"
p1:gravity="fill"
p1:textSize="25dp"
p1:layout_below="@id/nomeJogador1" />
<TextView
p1:text="Jogadas: "
p1:layout_width="match_parent"
p1:layout_height="35dp"
p1:id="@+id/jogadas"
p1:gravity="center"
p1:textSize="25dp"
p1:layout_below="@+id/nomeJogador2"
p1:layout_marginBottom="5dp"
p1:layout_marginRight="5dp"
p1:layout_marginLeft="5dp" />
<TextView
p1:text="Vencedor: "
p1:layout_width="match_parent"
p1:layout_height="35dp"
p1:id="@+id/vencedor"
p1:gravity="center"
p1:textSize="25dp"
p1:layout_below="@+id/jogadas"
p1:padding="5dp"
p1:layout_marginBottom="5dp"
p1:layout_marginLeft="5dp"
p1:layout_marginRight="5dp" />
</RelativeLayout>
<LinearLayout
p1:layout_width="match_parent"
p1:layout_height="wrap_content"
p1:orientation="vertical"
p1:weightSum="3"
p1:background="@drawable/velha"
p1:layout_weight="3"
p1:id="@+id/linearLayout5"
p1:layout_marginBottom="10dp"
p1:layout_marginLeft="5dp"
p1:layout_marginRight="5dp"
p1:layout_marginTop="5dp">
<LinearLayout
p1:layout_width="match_parent"
p1:layout_height="0dp"
p1:layout_weight="1"
p1:orientation="horizontal"
p1:weightSum="3"
p1:id="@+id/linearLayout2">
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos00"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos01"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos02"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
</LinearLayout>
<LinearLayout
p1:layout_width="match_parent"
p1:layout_height="0dp"
p1:layout_weight="1"
p1:orientation="horizontal"
p1:weightSum="3"
p1:id="@+id/linearLayout3">
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos10"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos11"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos12"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
</LinearLayout>
<LinearLayout
p1:layout_width="match_parent"
p1:layout_height="0dp"
p1:layout_weight="1"
p1:orientation="horizontal"
p1:weightSum="3"
p1:id="@+id/linearLayout4">
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos20"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos21"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
<Button xmlns:tools="http://schemas.android.com/tools"
p1:id="@+id/pos22"
p1:layout_width="0dp"
p1:layout_height="fill_parent"
p1:layout_weight="1"
tools:visibility="visible"
p1:scaleType="centerInside"
p1:background="@android:color/transparent" />
</LinearLayout>
</LinearLayout>
<Button
p1:text="Voltar"
p1:layout_width="match_parent"
p1:layout_height="wrap_content"
p1:id="@+id/btnVoltar"
p1:layout_gravity="bottom"
p1:textSize="20dp"
p1:layout_marginLeft="5dp"
p1:layout_marginRight="5dp"
p1:layout_weight="0" />
</LinearLayout>
有什么办法解决吗?
PS:两周前开始使用 Xamarin,所以对我来说一些编码理解有点困难 =/
谢谢!
编辑 -解决方案:
我遵循了 jzeferino 的提示,并进行了更多研究。即使在他的提示之后,布局仍然不是它应该的样子。所以我意识到问题出在状态栏高度上。在更改布局中的一些小问题后,我所要做的就是创建一个方法来获取 return 它的高度
public int getStatusBarHeight()
{
int statusBarHeight = 0;
int resourceId = Resources.GetIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0)
{
statusBarHeight = Resources.GetDimensionPixelSize(resourceId);
}
return statusBarHeight;
}
为了在后面的行janela.ShowAsDropDown(popup, Android.Views.ViewGroup.LayoutParams.MatchParent, tam);
中作为参数使用,其中int tam = getStatusBarHeight();
而最后的结果是this one
我需要改变一些东西。 尽量不要在 layout_height 和 layout_width 上使用那么多固定维度。 您使用的权重不正确。我删除了它。
最终代码(注意我需要更改资源名称):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp">
<ImageView
android:id="@+id/xJogadorBranco"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_margin="5dp"
android:src="@drawable/icno" />
<ImageView
android:id="@+id/oJogadorBranco"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_below="@id/xJogadorBranco"
android:layout_margin="5dp"
android:src="@drawable/icno" />
<TextView
android:id="@+id/nomeJogador1"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_margin="5dp"
android:layout_toRightOf="@id/xJogadorBranco"
android:gravity="fill"
android:text="Jogador 1"
android:textSize="25dp" />
<TextView
android:id="@+id/nomeJogador2"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_below="@id/nomeJogador1"
android:layout_margin="5dp"
android:layout_toRightOf="@id/oJogadorBranco"
android:gravity="fill"
android:text="Jogador 2"
android:textSize="25dp" />
<TextView
android:id="@+id/jogadas"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/nomeJogador2"
android:layout_margin="3dp"
android:gravity="center"
android:text="Jogadas: "
android:textSize="25dp" />
<TextView
android:id="@+id/vencedor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/jogadas"
android:layout_margin="3dp"
android:gravity="center"
android:text="Vencedor: "
android:textSize="25dp" />
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/grid"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos00"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos01"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos02"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos10"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos11"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos12"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos20"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos21"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
<Button xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pos22"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@android:color/transparent"
android:scaleType="centerInside"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/btnVoltar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:text="Voltar"
android:textSize="20dp" />
</LinearLayout>
结果: