android - layout_weight =".4"看起来比 layout_weight =".6"大

标签 android android-layout

这个。如果最后一个布局有 .6 (60%),我不明白为什么第一个布局看起来比第二个布局大。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight=".4" >

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight=".6">
    </RelativeLayout>
</LinearLayout>

最佳答案

@Miguel Barra 适用于此

   android:layout_width="match_parent"

替换为

   android:layout_width="wrap_content"

   android:layout_width="0dp"

在你的 both Relative 布局中

关于android - layout_weight =".4"看起来比 layout_weight =".6"大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41688963/

相关文章:

android - 为什么 FrameLayout 没有在我的布局中正确设置 Z 顺序?

android - 如何在 RecyclerView 中显示确切的项目数量?

java - 当我们到达 Horizo​​ntalScrollView 中的最后一项时指示器消失

android - 如何在 GridView 中设置图像大小

android - 是否可以在同一个 Activity 中有 2 个上下文菜单?

java - 将 EditText 名称获取到数组变量 android

android - 如何覆盖xml中的默认背景颜色?

Android:Recyclerview 中的水平线 View 在滚动时闪烁

Android - 暂停所有线程花费了 : * ms

android - 当应用程序从低内存中返回时系统重新创建 fragment