我如何实现固定的宽高比View?我想要一个宽高比为1:1的物品GridView.我认为将孩子分类比把它分类更好GridView?
编辑:我认为这需要以编程方式完成,这没问题.另外,我不想限制大小,只限制宽高比.
我想布局如下的视图,但我不知道如何这样做:
这是我想象的一个小图片:
.----------------------.
| .--------------. |
| b | | b |
| g | | g |
| | | |
| i | MySurface | i |
| m | View | m |
| a | | a |
| g | (2:3 w:h) | g |
| e | | e |
| *--------------* |
|.--------------------.|
|| ||
|| SomeOtherView ||
|| ||
|*--------------------*|
*----------------------*
Run Code Online (Sandbox Code Playgroud)
就设置MySurfaceView而言,我认为普通的layout_width和layout_height对我没有帮助,因为直到屏幕部分布局并SomeOtherView放置之后我才知道可用的屏幕尺寸.
是否有一些函数MySurfaceView需要覆盖,例如将作为参数传递可用的屏幕空间,让我决定如何设置视图的宽度和高度?
"通货膨胀"是我正在寻找的正确名词吗?我认为这与我正在寻找的东西有关,但我真的不知道术语.
我尝试使用PercentFrameLayout但我收到此错误消息:
Binary XML file line #: You must supply a layout_width attribute.
Run Code Online (Sandbox Code Playgroud)
这是我使用的xml:
<android.support.percent.PercentFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
app:layout_heightPercent="50%"
app:layout_marginLeftPercent="25%"
app:layout_marginTopPercent="25%"
app:layout_widthPercent="50%"/>
</android.support.percent.PercentFrameLayout>
Run Code Online (Sandbox Code Playgroud)
这是一个错误还是我的错?
android android-layout android-percent-library android-percent-layout
我想在android中旋转图像.我发现这个有用的帖子,它的效果很好,但似乎在android中的旋转从左下角开始.我需要从中心点旋转图像.可能吗?代码相同是有帮助的.谢谢.