Android对话框与自定义布局挤压组件一起
我有一个自定义的对话框布局,我想使用,但当我使用它出来的错误大小和挤压所有东西在一起。 这是我的布局代码(抱歉有点长): 我是否可以像其他对话框一样,使对话框本身的大小刚好足以容纳其中的内容?Android对话框与自定义布局挤压组件一起,android,android-layout,dialog,Android,Android Layout,Dialog,我有一个自定义的对话框布局,我想使用,但当我使用它出来的错误大小和挤压所有东西在一起。 这是我的布局代码(抱歉有点长): 我是否可以像其他对话框一样,使对话框本身的大小刚好足以容纳其中的内容? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="m
<?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:padding="10dp" >
调用match\u parent将根据需要自动调整宽度
调用match_parent会根据需要自动调整宽度这似乎会产生相同的结果所有东西看起来都被压扁了不确定为什么会有很多线性布局,使用表格布局或网格布局可能是一个好主意。这似乎会产生相同的结果,但一切看起来仍然不稳定。不知道为什么会有一堆线性布局,使用表格布局或网格布局可能是一个好主意。
Context mContext = TaskListActivity.this;
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.new_note);
dialog.setTitle("Add Task");
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:padding="10dp" >