0
  • 最佳答案

    感谢大家解答,是因为我做绘制的时候,返回的bitmap做了拉伸后,横屏的时候忘记处理拉伸的比例导致的

    1538868970726100993  评论     打赏       shiw
    • 相似代码 可以铺满全屏

      mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
          @Override
          public void onPrepared(final MediaPlayer mp) {
              // 点击过快可能导致mp未解析完成 故延时
              handler.postDelayed(()-> {
                  if (mp == null) {
                      JXLog.e("mediaListener onPrepared mp is null ");
                      return;
                  }
                  jxSurface.setPause(false);
                  int vWidth = mp.getVideoWidth();
                  int vHeight = mp.getVideoHeight();
                  // 该LinearLayout的父容器 android:orientation="vertical" 必须
                  LinearLayout linearLayout = (LinearLayout) findViewById(R.id.layoutPlay);
                  int lw = linearLayout.getWidth();
                  int lh = linearLayout.getHeight();
                  float wRatio = (float) vWidth / (float) lw;
                  float hRatio = (float) vHeight / (float) lh;
                  // 选择大的一个进行缩放
                  float ratio = Math.max(wRatio, hRatio);
                  vWidth = (int) Math.ceil((float) vWidth / ratio);
                  vHeight = (int) Math.ceil((float) vHeight / ratio);
                  // 设置surfaceView的布局参数
                  LinearLayout.LayoutParams lp= new LinearLayout.LayoutParams(vWidth, vHeight);
                  lp.gravity = Gravity.CENTER;
                  jxSurface.setLayoutParams(lp);
                  jxSurface.setPlaying(true);
                  mediaPlayer.start();
              },100);
          }
      });
      


      1382711465131241472  评论     打赏       阿肥
      • 并没有铺满 代码呢 布局呢 不能只给几张图让大家伙猜吧

        1382711465131241472  评论     打赏       阿肥
        • 看看布局?
          1247069679944470528  评论     打赏       MUZIII
          • 有没有可能,高度你写死了,或者wrap?
            1139423796017500160  评论     打赏       断点
            相关问题
            风走过的痕迹 · 视频
            2020-08-03 06:05 390 2
            小雷雷 · 视频
            2020-10-27 07:41 357 2
            小羊 · 视频
            2021-05-10 22:26 190 2
            yesen · 视频
            2021-07-20 19:17 255 2
            liweichao21 · 观看视频
            2021-07-24 09:03 462 2
            2021-10-28 23:37 428 20
            2021-12-03 23:44 408 2
            资质平平 · Android
            2025-02-20 09:14 92 100
            尖沙咀-段坤 · 项目
            2025-01-06 23:39 18 2
            雅澤yaduo · 领券联盟
            2025-01-03 20:39 37 50