在弹出窗口中显示一个 viewpager window
Display a viewpager on popup window
在弹出窗口中显示 viewpager 时遇到问题 window。
想要在实际上是弹出窗口的 viewpager 上显示多个图像 window。但无法删除 window.
的边空格
Viewpager
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" />
ImageView
<com.utility.TouchImageView
android:id="@+id/imgDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
xmlns:android="http://schemas.android.com/apk/res/android" />
如果您使用的是包含 viewpager 的对话框
您可以将以下样式设置为该对话框,如
dialog.setStyle(STYLE_NO_TITLE, R.style.DialogStyle);
对话框样式
<style name="DialogStyle" parent="Base.Theme.AppCompat.Dialog">
<item name="android:windowMinWidthMajor">100%</item>
<item name="android:windowMinWidthMinor">100%</item>
</style>
或者您可以计算屏幕宽度并将其作为
传递给对话框宽度
Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
popUpLayout = Globals.layoutInflater.inflate(R.layout.pop_up_layout,
null);
dialog.setContentView(popUpLayout);
dialog.getWindow().setLayout(Desired_Width, Desired_Hight);
dialog.show();
试试这个它会删除边距并将您的对话框显示为全屏(无边距)
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
上一行是最重要的,千万不要错过。
final Dialog dialog = new Dialog(getActivity(), R.style.DialogAnimation);
dialog.getWindow().getAttributes().windowAnimations =
R.style.DialogOpenAnimation;
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(true);
dialog.setContentView(R.layout.dialog_mediagallary);
ImageButton back_arrow = (ImageButton) dialog.findViewById(R.id.back);
viewPagerPhotoSlideShow = (ClickableViewPager) dialog.findViewById(R.id.photolist);
adapterPhotoViewPager = new AdaterViewPagerAllmeidagallary(getActivity(), pagerListItems);
viewPagerPhotoSlideShow.setAdapter(adapterPhotoViewPager);
viewPagerPhotoSlideShow.setCurrentItem(defaultPagerItemPosition);
back_arrow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
lp.gravity = Gravity.CENTER;
Window window = dialog.getWindow();
window.setAttributes(lp);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
在弹出窗口中显示 viewpager 时遇到问题 window。
想要在实际上是弹出窗口的 viewpager 上显示多个图像 window。但无法删除 window.
Viewpager
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" />
ImageView
<com.utility.TouchImageView
android:id="@+id/imgDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitCenter"
xmlns:android="http://schemas.android.com/apk/res/android" />
如果您使用的是包含 viewpager 的对话框
您可以将以下样式设置为该对话框,如
dialog.setStyle(STYLE_NO_TITLE, R.style.DialogStyle);
对话框样式
<style name="DialogStyle" parent="Base.Theme.AppCompat.Dialog">
<item name="android:windowMinWidthMajor">100%</item>
<item name="android:windowMinWidthMinor">100%</item>
</style>
或者您可以计算屏幕宽度并将其作为
传递给对话框宽度Dialog dialog = new Dialog(MainActivity.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
popUpLayout = Globals.layoutInflater.inflate(R.layout.pop_up_layout,
null);
dialog.setContentView(popUpLayout);
dialog.getWindow().setLayout(Desired_Width, Desired_Hight);
dialog.show();
试试这个它会删除边距并将您的对话框显示为全屏(无边距)
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
上一行是最重要的,千万不要错过。
final Dialog dialog = new Dialog(getActivity(), R.style.DialogAnimation);
dialog.getWindow().getAttributes().windowAnimations =
R.style.DialogOpenAnimation;
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCanceledOnTouchOutside(false);
dialog.setCancelable(true);
dialog.setContentView(R.layout.dialog_mediagallary);
ImageButton back_arrow = (ImageButton) dialog.findViewById(R.id.back);
viewPagerPhotoSlideShow = (ClickableViewPager) dialog.findViewById(R.id.photolist);
adapterPhotoViewPager = new AdaterViewPagerAllmeidagallary(getActivity(), pagerListItems);
viewPagerPhotoSlideShow.setAdapter(adapterPhotoViewPager);
viewPagerPhotoSlideShow.setCurrentItem(defaultPagerItemPosition);
back_arrow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
lp.gravity = Gravity.CENTER;
Window window = dialog.getWindow();
window.setAttributes(lp);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();