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  评论     打赏       断点
            相关问题
            幻影~ · 安卓
            2024-04-26 19:25 7 4
            deanhu · AOSP
            2024-04-25 21:53 3 10
            幻影~ · 提问
            2024-04-13 20:13 10 2
            幻影~ · 找工作
            2024-04-07 10:44 17 2
            幻影~ · 问题
            2024-03-31 17:20 7 2
            TONYGFX · AOSP
            2024-03-28 17:11 4 2