とのアバウト ダイアログがありRelativeLayout
ます。通常のアクティビティでは正しく動作しますが、に移動することにしたときDialogFragment
、ほとんどのアライメント ルールが機能しなくなりました。レイアウトは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="250dp" >
<TextView
android:id="@+id/label_copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="20dp"
android:text="Copyright (c) 2013 Copyright"
android:textSize="8dp" />
<TextView
android:id="@+id/label_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@+id/label_copyright"
android:layout_marginTop="2dp"
android:text="@null" />
<TextView
android:id="@+id/label_app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/label_version"
android:layout_centerHorizontal="true"
android:layout_marginBottom="2dp"
android:text="Application Name"
android:textSize="25dp" />
<ImageView
android:id="@+id/image_app_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/label_app_name"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:src="@drawable/field_public_required" />
<TextView
android:id="@+id/label_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/label_copyright"
android:layout_marginTop="30dp"
android:gravity="center"
android:autoLink="web"
android:text="application description with more details" />
</RelativeLayout>
これがどのように機能するかは次のとおりです。実際にアクティビティで機能します (Eclipse のグラフィカル レイアウトのスクリーンショット)。
そして、フラグメントを使用してアプリケーションを実行すると、次のようになります。
どうやら、最初のビューのみが予想どおり中央に配置され、他のすべてのビューは一番上に押し上げられているようです。レイアウトでどちらminHeight
を指定しても、動作は常に同じです。
ダイアログをインスタンス化するコードは非常に単純です。
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.about, null);
try
{
TextView t = (TextView)view.findViewById(R.id.label_version);
t.setText(getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName);
}
catch(NameNotFoundException e)
{
}
return new AlertDialog.Builder(getActivity())
.setView(view)
.setTitle(R.string.about)
.setPositiveButton(R.string.ok,
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
}
}
)
.create();
}
何が問題で、どのように修正するのですか?