Android LinearLayout 制作按钮不起作用 [英] Android LinearLayout make button doesn't work

查看:38
本文介绍了Android LinearLayout 制作按钮不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的布局中有很多按钮,它们运行良好.我想将两个按钮放在同一行上,所以我使 LinearLayout 水平,但是当我这样做时,第二个按钮的单击事件不起作用.它没有显示我的文本视图

I have many buttons in my layout and they work well. I want to put the two buttons on the same row, so I make a LinearLayout horizontal, but when I do that, the second button's click event doesn't work. It doesn't show me my textview

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

        <Button
            android:id="@+id/bAnswerQuestoinShowChoices"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Show Choices"
            android:visibility="invisible" />

        <Button
            android:id="@+id/bAnswerQuestionShowHints"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Show Hint 1"
            android:visibility="invisible" />
    </LinearLayout>

如果我删除 LinearLayout 它工作正常,但我想要线性布局,因为我希望两个按钮在同一行.

If I remove the LinearLayout it works fine, but I want the linearlayout because I want the two buttons to be on the same row.

推荐答案

android:layout_height="match_parent"//<----------------------这是问题使它扭曲内容

android:layout_height="match_parent" //<----------------------this is the issue make it warp content

<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" //<----------------------this is the issue make it warp content
        android:orientation="horizontal" >

这篇关于Android LinearLayout 制作按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆