안녕하십니까!
listView 팝업에 문제가 있습니다.
목록 요소 중 하나를 클릭하면 팝업이 나타나고 게임의 모든 정보 (해당 게임의 TicTacToe 내역)를 표시합니다. 모달에 대한 레이아웃을 완료했으며 미리보기에서 원하는대로 표시하고 있습니다.
하지만 내 안드로이드에서 실행할 때, 일부 요소는 ... as shown here을 "컷"입니다팝업 창이 예상대로 표시되지 않음 (Android/Xamarin)
현재 활동 코드 :
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>
어떤 ideias 그것을 해결하는 방법?
추신 : 2 주 전에 Xamarin을 시작 했으므로 나를 위해 몇 가지 코딩을하지 않아도된다. =/
고마워!
EDIT - 솔루션 :
jzeferino 팁을 따라 갔고 조금 더 연구했습니다. 그의 조언 후에도, 레이아웃은 여전히 그래야만하는 것이 아니 었습니다. 그래서 문제는 STATUS BAR 높이와 관련이 있다는 것을 깨달았습니다. 내 레이아웃에 약간의 문제를 변경 한 후 내가했던 일은, 높이 얻고 반환하는 방법을 만들 수있는 다음 라인 janela.ShowAsDropDown(popup, Android.Views.ViewGroup.LayoutParams.MatchParent, tam);
int tam = getStatusBarHeight();
그리고에 매개 변수로 사용하기 위해서는
public int getStatusBarHeight()
{
int statusBarHeight = 0;
int resourceId = Resources.GetIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0)
{
statusBarHeight = Resources.GetDimensionPixelSize(resourceId);
}
return statusBarHeight;
}
최종 결과는 this one
합니다. – jzeferino
내가 한 ... 첫 번째 이미지는 내 모달의 레이아웃입니다 –
코드에 대해 이야기하고있었습니다. – jzeferino