Skip to content

Commit

Permalink
修复竖屏模式下相机预览图像压缩的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
szitguy committed Sep 14, 2015
1 parent 5b89ad7 commit d86a29b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 45 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures

# IntelliJ
/*.iml
/*.ipr
/*.iws
/.idea
/out/
3 changes: 3 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/build

# IntelliJ
/*.iml
2 changes: 1 addition & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="leakcanary-android-1.3.1" level="project" />
<orderEntry type="library" exported="" name="leakcanary-watcher-1.3.1" level="project" />
<orderEntry type="library" exported="" name="haha-1.3" level="project" />
<orderEntry type="library" exported="" name="leakcanary-watcher-1.3.1" level="project" />
<orderEntry type="library" exported="" name="leakcanary-analyzer-1.3.1" level="project" />
</component>
</module>
6 changes: 5 additions & 1 deletion app/src/main/java/cn/itguy/recordvideodemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ protected void onCreate(Bundle savedInstanceState) {
public void onGlobalLayout() {
preview.getViewTreeObserver().removeGlobalOnLayoutListener(this);
ViewGroup.LayoutParams layoutParams = preview.getLayoutParams();
layoutParams.height = (int) (4f * preview.getWidth() / 3);
layoutParams.height = (int) (3f / 4f * preview.getWidth());
preview.setLayoutParams(layoutParams);

ViewGroup.LayoutParams layoutParams2 = mPreview.getLayoutParams();
layoutParams2.height = (int) (4f / 3f * preview.getWidth());
mPreview.setLayoutParams(layoutParams2);
}
});

Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true"
>
<FrameLayout
android:id="@+id/camera_preview"
Expand Down

0 comments on commit d86a29b

Please sign in to comment.