android - 在 LinearLayout 中使用权重时如何保持纵横比?

标签 android

我有一个垂直的 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/

相关文章:

c# - 如何在我的统一创建的 android 应用程序中显示导航栏

android - 无法连接到 Android 中的节点 js 服务器

android - 在应用程序类中绑定(bind) Android 服务是个好主意吗?

android - 防止 fragment 在方向更改时重新加载

android - com.google.android.gms.internal.* 引起的内存泄漏

android - 在 Flutter App "task assembleDebug failed with exit code 1"上构建失败

android - 单击时不要将按钮置于前台

java - 如何在Android中返回FileInputStream的值

android - 无法在 Android Oreo 上将通知优先级设置为低

Android 布局 - ImageView 聚焦,但不在屏幕上显示任何内容(无突出显示)