【问题标题】:Android DialogFragmant layout not show all layout elementsAndroid DialogFragment 布局不显示所有布局元素
【发布时间】:2013-06-07 20:00:14
【问题描述】:

我正在尝试从 FragmanActivity 调用对话框片段。 我的对话框片段包括两个编辑文本视图和两个按钮。

我阅读了 android 开发者用户指南,但我无法解决我的问题。 (Fragments) 我的问题是:DialogFragment 窗口看起来只是一个小窗口。

我的对话框 XML:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="400dp"
android:layout_height="790dp"
android:orientation="horizontal" >

<EditText
   android:id="@+id/ePostionDate"
   android:inputType="date"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:hint="@string/lblDate"
   android:focusableInTouchMode="false"
   android:paddingLeft="5dip" />

<EditText
   android:id="@+id/eWaterPosition"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:inputType="numberDecimal"
   android:hint="@string/lblWaterPostion"
   android:paddingLeft="5dip" />

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1.0" >

    <TableRow>
        <Button
            android:id="@+id/btnAddWaterposition"
            android:layout_width="0dp"
            android:layout_weight=".50"
            android:layout_height="wrap_content"
            android:text="@string/lblBtnFixData"
            android:layout_gravity="left" />
        <Button
            android:id="@+id/btnCancelWaterposition"
            android:layout_width="0dp"
            android:layout_weight=".50"
            android:layout_height="wrap_content"
            android:text="@string/lblBtnCancel"
            android:layout_gravity="right" />
    </TableRow>
</TableLayout>

我尝试调用 DialogFragment 的 FragmentActivity 的一部分:

        DialogFragment wpDialog = new WaterPositionEditActivity(getApplicationContext());
    wpDialog.show(getSupportFragmentManager(), "waterPositionSetter");

最后是我的 DialogFragment 类:

enter code here

@SuppressLint("ValidFragment") 公共类 WaterPositionEditActivity 扩展 DialogFragment {

private Context context;

public WaterPositionEditActivity(Context context) {
    super();
    this.context = context;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.water_position, container, false);
}

}

我为 Android 2.2 创建了我的应用,但我希望它可以在 Android4 或更高版本上运行。

非常小的窗口如下所示:

正如您在 img 上看到的,只有一个 edittext 字段显示,但还有另一个 editview 和两个按钮。所以这个小窗口应该比现在大,并显示所有布局元素!

谁能帮忙解决一下?

【问题讨论】:

    标签: android dialog android-dialogfragment


    【解决方案1】:

    我找到了解决方案。我使用RelativeLayout 我忘了在XML 布局中为元素添加正确的位置。 当我为元素添加正确的位置时,对话框窗口会按需要显示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      相关资源
      最近更新 更多