如何从FragmentDialog中删除多余的空间?

时间:2014-04-09 01:09:41

标签: android android-fragments android-imageview

这个片段的代码

package cofm.example.dgdg;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

public class ImageFragment extends android.support.v4.app.DialogFragment {

    private ImageView mImageView;

    public static ImageFragment newInstance() {

        ImageFragment fragment = new ImageFragment();
        fragment.setStyle(DialogFragment.STYLE_NO_TITLE, 0);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        mImageView = new ImageView(getActivity());
        mImageView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

            }
        });

        mImageView.setImageResource(R.drawable.pic1);
        // mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

        return mImageView;
    }

    @Override
    public void onDestroyView() {

    }

}

如何从FragmentDialog中删除多余的黑色空间? 这里带有黑色冗余空间的图片..!

https://www.dropbox.com/s/0nmv24fbkd2dv30/land.jpg

这是来源 https://www.dropbox.com/s/sq5j1o4rnkdbiec/project.zip

如何从FragmentDialog中删除多余的黑色空间? setAdjustViewBounds对我不起作用

1 个答案:

答案 0 :(得分:0)

将一个样式设置为DialogFragment为无帧

    setStyle(DialogFragment.STYLE_NO_FRAME,0);

实施例..

    DialogFragment newFragment = ImageFragment.newInstance();
    newFragment.setStyle(DialogFragment.STYLE_NO_FRAME,0);
    newFragment.show(getSupportFragmentManager().beginTransaction(), "dialog");