【问题标题】:Image is not fullscreen图片不是全屏
【发布时间】:2015-05-05 09:06:58
【问题描述】:

我想将image 显示为fullscreen

public class PhotoPleinEcranActivity extends Activity {

    private Bundle data;
    private ImageView img;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.photo_plein_ecran);

        img = (ImageView)findViewById(R.id.zoom);

        BitmapFactory.Options bfOptions = new BitmapFactory.Options();
        bfOptions.inDither = true;                     //Disable Dithering mode
        bfOptions.inPurgeable = true;                   //Tell to gc that whether it needs free memory, the Bitmap can be cleared
        bfOptions.inInputShareable = true;              //Which kind of reference will be used to recover the Bitmap data after being clear, when it will be used in the future
        bfOptions.inTempStorage = new byte[32 * 1024];

        data = getIntent().getExtras();

        FileInputStream fs = null;
        Bitmap bm;
        try {
            fs = new FileInputStream(new File(data.getString("path")));
            if(fs != null) {
                bm = BitmapFactory.decodeFileDescriptor(fs.getFD(), null, bfOptions);
                img.setImageBitmap(bm);
            }
        } catch (IOException e) {
        } finally {
            if(fs != null) {
                try {
                    fs.close();
                } catch (IOException e) {
                }
            }
        }

    }

}

布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginTop="0dip"
    android:layout_marginBottom="0dip"
    android:paddingTop="0dip"
    android:paddingBottom="0dip"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/zoom"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="0dip"
        android:layout_marginBottom="0dip"
        android:paddingTop="0dip"
        android:paddingBottom="0dip"
    />

</LinearLayout>

清单文件:

<activity
     android:name="com.ambre.impots.PhotoPleinEcranActivity"
     android:label="@string/galleryPhotos"
     android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>

在运行时,图像底部有一个灰色区域(我用黄色包围了灰色区域):

那么如何让那个灰色区域消失呢?

【问题讨论】:

标签: android


【解决方案1】:

像这样改变你的图像视图

 <ImageView
    android:id="@+id/zoom"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="0dip"
    android:layout_marginTop="0dip"
    android:adjustViewBounds="true"
    android:paddingBottom="0dip"
    android:paddingTop="0dip"
    android:scaleType="fitXY" />

【讨论】:

    【解决方案2】:

    这将解决您的问题。

    在 ImageView 中添加以下行。

    android:scaleType="fitXY"
    

    【讨论】:

      【解决方案3】:

      android:scaleType="fitXY" 添加到您的ImageView,fitXY,将独立填充宽度和高度以匹配目标

      【讨论】:

        【解决方案4】:

        像这样将属性 scaleType 添加到 fitXY

        <ImageView
                android:id="@+id/zoom"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_marginTop="0dip"
                android:layout_marginBottom="0dip"
                android:paddingTop="0dip"
                android:paddingBottom="0dip"
                android:scaleType="fitXY" />
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-09-29
          • 2017-10-07
          相关资源
          最近更新 更多