android 自定义Dialog 显示有关问题 ?请求解决
android 自定义Dialog 显示问题 请求解决
请看图,希望只把红线圈的显示出来,XML只有红线圈的这么大
代码
Dialog dialog = new Dialog(getActivity());
dialog.setContentView(R.layout.edit_colorchange_dialog);<br />
Window dialogWindow = dialog.getWindow();<br />
WindowManager.LayoutParams lp = dialogWindow.getAttributes();<br />
lp.x = 100; <br />
lp.y = -300; <br />
dialogWindow.setAttributes(lp);
dialog.show();<br />
layout.xml
< xml version="1.0" encoding="utf-8" >
<LinearLayout xmlns:android=""
android:layout_width="266.4sp"
android:layout_height="58.6sp"
android:orientation="vertical" >
<LinearLayout
android:layoutwidth="wrapcontent"
android:layoutheight="wrapcontent"
android:background="@drawable/zhengwen_xuanyanse" >
</LinearLayout>
</LinearLayout>
Answers
Dialog dialog = new Dialog(MainActivity.this, R.style.dialog);
ImageView img = new ImageView(MainActivity.this);
img.setImageResource(R.drawable.a);
img.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT));
dialog.setContentView(img);
dialog.show();
<style name="dialog" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>