我如何实现固定的宽高比View?我想要一个宽高比为1:1的物品GridView.我认为将孩子分类比把它分类更好GridView?
编辑:我认为这需要以编程方式完成,这没问题.另外,我不想限制大小,只限制宽高比.
我尝试在视图上实现16:9的宽高比PercentRelativeLayout.
所以我把这行放在build.gradle文件中: compile 'com.android.support:design:23.0.1'
我用这个布局:
<android.support.percent.PercentRelativeLayout
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="wrap_content">
<ImageView
android:layout_width="match_parent"
app:layout_aspectRatio="178%"
android:scaleType="centerCrop"/>
</android.support.percent.PercentRelativeLayout>
Run Code Online (Sandbox Code Playgroud)
问题:
'layout_height' should be defined为了ImageView.Error:(15) No resource identifier found for attribute 'layout_aspectRatio'.那有什么不对?
android android-layout android-constraintlayout android-percentrelativelayout