Android LinearLayout make button doesn't work

2019-07-28 14:14发布

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条回答
家丑人穷心不美
2楼-- · 2019-07-28 15:00

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" >
查看更多
登录 后发表回答