我的目标是创建一个对话框,其中包含其内容高度,如下图所示。包装内容无法用于对话框
我的问题是,我想要的对话框如下图所示的图像中,以匹配其母公司。高度应该停在“asdf”这个项目上,这个“asdf”下面的空白不应该存在。
这是我后来的代码:
private void showPopupEventTest(final String Cardid) {
Dialog dialog = new Dialog(getActivity(), R.style.Theme_AppCompat_Dialog_Alert);
dialog.getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
dialog.setContentView(R.layout.fragment_event);
SwipeRefreshLayout swipeRefreshLt = (SwipeRefreshLayout) dialog.findViewById(R.id.swipeRefreshLt);
ListView lv = (ListView) dialog.findViewById(R.id.Contacts_list_view);
SearchView SearchET = (SearchView) dialog.findViewById(R.id.SearchET);
LinearLayout layoutLinearLayout = (LinearLayout) dialog.findViewById(R.id.layoutLinearLayout);
EventAdaptor myAdapter = new EventAdaptor(getContext(), ArrayList_EventObject);
lv.setAdapter(myAdapter);
dialog.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
dialog.show();
}
这是布局:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/layoutLinearLayout"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp">
<SearchView
android:id="@+id/SearchET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:iconifiedByDefault="false" />
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:id="@+id/swipeRefreshLt"
android:layout_height="wrap_content">
<ListView
android:id="@+id/Contacts_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
我在做什么错?
请张贴对话框的布局文件的代码。 –