当我创建自定义对话框时,它看起来像这样:
但我希望它看起来像这样:
您可以使用自定义对话框并将您设计的 xml 膨胀到其中。
final Dialog yourDialog=new Dialog(context);
thumbnail_click.setContentView(R.layout.yourlayout);
创建一个扩展 Dialog 的类并将其扩展为您的布局
public class CustomDialog extends Dialog
{
public CustomDialog (Context context)
{
//use this Theme, or any other theme you like
super(context, android.R.style.Theme_Translucent_NoTitleBar);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.your_layout);
}
}
如果您还没有得到答案,这里有一个很好的教程:Toturial
您需要制作自己的 XML 形状样式文件,并使用角函数 ex:
<corners android:bottomLeftRadius="5dp" android:bottomRightRadius="5dp" />
您始终可以扩展您自己的自定义对话框布局。
LayoutInflater inflater = getLayoutInflater();
View dialoglayout = inflater.inflate(R.layout.dialog_layout, (ViewGroup) findViewById(R.id.dialog_layout_root));
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(dialoglayout);