当前位置: 首页 > 知识库问答 >
问题:

ANDROID linearlayout使用权重填充remay空间

昝唯
2023-03-14

我正在尝试获取我的控件,以便显示一个控件,该控件的按钮和图像占用了剩余空间。我一直在考虑使用权重,我可以让它在宽度上工作,但一旦我在高度上使用权重,就不会显示任何内容,我的代码如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:baselineAligned="true" android:weightSum="100">

        <com.example.test.MyImageView
            android:id="@+id/test_img" 
            android:layout_height="0dp"         
            android:layout_width="wrap_content"
            android:layout_weight="75"
            android:scaleType="fitCenter"       
             />

       <Button
        android:id="@+id/RedrawBtn"
        android:layout_height="0dp"     
        android:layout_width="wrap_content"     
        android:layout_weight="25"
        android:text="Button" /> 
    </LinearLayout>
</RelativeLayout>

共有1个答案

益英逸
2023-03-14

您尚未为LinearLayout指定方向

<LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:baselineAligned="true" android:weightSum="100"
    android:orientation="vertical">

    <com.example.test.MyImageView
        android:id="@+id/test_img" 
        android:layout_height="0dp"         
        android:layout_width="wrap_content"
        android:layout_weight="75"
        android:scaleType="fitCenter"       
         />

   <Button
    android:id="@+id/RedrawBtn"
    android:layout_height="0dp"     
    android:layout_width="wrap_content"     
    android:layout_weight="25"
    android:text="Button" /> 
</LinearLayout>
 类似资料:
  • 我在SQL Server 2012中有两个表 表1 表2 每个用户可以拥有1到8个权限。 我需要创建一个视图,该视图将为我提供具有8个权限条目的UserID,其中任何未使用的条目都包含null值,即条目的顺序无关紧要。 这让我很困惑,我甚至不知道从哪里开始?

  • 我有一个基本的flexbox布局,如下所示。。 我试图使顶部的div填充剩余的空间,底部的div是动态的,因此高度根据文本的不同而变化。我的结果是这样的。。 在这种情况下,flexbox是最好的选择吗?

  • 我喜欢用基于其他列的Formel填充列中的空值: 你能看出我的代码有什么问题吗?因为这段代码后面有一些nulll值。 我的数据框: Datadate|datacqtr 2002-02-28|2002Q1 Dataacqtr代表四分之一。有时我有datadate,但没有datacqtr(四分之一)。所以我喜欢填充基于colmn数据的colmn datacqtr。

  • 我正在尝试合并两个数据帧: 第一个数据帧,,用INTEGERS/STRINGS填充 左边的数据框一起被整数/列表填充。 当我使用pandas函数时,新的数据框将用NaN填充右侧的数据框,而不是列表 我期望使用两个原始数据帧中的值创建一个新的合并数据帧。相反,在新的数据框中,“control”数据框中的所有值都是正确的,但“together”数据框中的所有列表都是正确的 以下是一些样本数据: 以下是

  • 我试图输出一个矩阵:

  • 我目前正在尝试将网站上使用的徽标应用于打印页面上的某个位置。这样做,我想以不同的方式填充它。然而,填充效果似乎不起作用。 当我在单独的选项卡中查看logo.svg并检查它时,我可以成功地用新颜色填充它的两个组件中的每一个。 但是,当我将它作为背景图像带入打印页面上的DIV时,填充不再起作用。有人能告诉我这是什么原因吗? 在SVG页面上,我可以成功地完成以下操作。 (正如我前面提到的,SVG似乎由两