简体   繁体   English

如何在线性布局中对齐textview下方的按钮

[英]How to align buttons below textview in linear layout

I have a table and for each cell I have text and three buttons. 我有一张桌子,每个单元格都有文字和三个按钮。

I want the buttons to be aligned right below the text view but I can't get them to align like that. 我希望按钮在文本视图的正下方对齐,但我不能让它们像那样对齐。

This is my layout: 这是我的布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:descendantFocusability="blocksDescendants">

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="15dip"
        android:paddingLeft="5dip"
        android:textStyle="bold"
        android:paddingTop="5dip"
        android:textColor="#000000"
        android:textSize="16dip"
        android:layout_toRightOf="@+id/track_no"/>

    <LinearLayout
        android:id="@+id/c1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <ImageButton ../>

        <ImageButton ../>

        <ImageButton ../>
    </LinearLayout>
</LinearLayout>

Have you tried changing your top LinearLayout 's orientation to vertical ? 您是否尝试将顶部LinearLayout的方向更改为vertical Something like this. 像这样的东西。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:descendantFocusability="blocksDescendants">

you have to use 你必须使用

  android:orientation="vertical"

instead of 代替

android:orientation="horizontal"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM