首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >安卓: layout_weight不支持按钮和LinearLayout

安卓: layout_weight不支持按钮和LinearLayout
EN

Stack Overflow用户
提问于 2018-06-13 06:05:05
回答 3查看 1.1K关注 0票数 1

我试图让所有的按钮都是相同的大小,并且都在屏幕的右侧,无论文本视图中有多少文本。

现在,按钮紧挨着垂直的LinearLayout (由2个TextViews组成),并且只有当其中一个TextViews超过一行时才会出现在正确的位置。

我尝试过将按钮添加到LinearLayout并给它一个权重,给每个TextViews一个权重,只给文本填充的LinearLayout一个权重,等等都没有用。

我现在想知道这是不是有问题,因为这不是主要的XML,而是一个重复的项目?但我不认为这会影响到它。

This is what it currently looks like

这是行项的XML:

代码语言:javascript
运行
复制
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<LinearLayout
    android:id="@+id/linearlayout"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Header" />

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50826487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档