Android LinearLayout make button doesn't work

天大地大妈咪最大 提交于 2019-12-24 08:57:05

问题


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>

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.


回答1:


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" >


来源:https://stackoverflow.com/questions/11170248/android-linearlayout-make-button-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!