写一个dialog对话框,使用了百分比布局,代码如下
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintWidth_percent="0.8"
app:layout_constraintHeight_percent="0.6"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@drawable/dial_show_code">
..............
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
展示在dialog里,代码如下
AlertDialog.Builder builder = new AlertDialog.Builder(context);
View inflate = LayoutInflater.from(context).inflate(R.layout.dialog_show_code, null);
builder.setView(inflate);
AlertDialog simpleDialog = builder.create();
simpleDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
simpleDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
simpleDialog.show();
simpleDialog.setCancelable(true);
结果显示不出来!!!!!!!!!!!!!
使用固定宽高,可以显示!!!!!!!!!!!!!!
请问大家这是什么原因????????????????