我有一个垂直的 LinearLayout,它包含两个 ImageView 和两个 Button。 ImageView 的权重总和为 70,Button 的权重总和为 30。这两个按钮具有指定的纵横比,当 Android 使用指定的权重调整它们的大小时,它仅通过改变纵横比来改变按钮的高度。
最佳答案
解决使用:
- 用 ImageButton 代替 Button
- android:src 而不是 android:background
- android:background="#00000000"
- android:scaleType="fitCenter"
- android:layout_width="match_parent"
- android:adjustViewBounds="true"
关于android - 在 LinearLayout 中使用权重时如何保持纵横比?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16255401/