Невозможно добавить более одной кнопки в линейном макете - PullRequest
0 голосов
/ 12 июня 2018

Я использую Linear Layout в своем коде и хочу добавить кнопки в свою деятельность, используя вертикальную полосу прокрутки.Но я не могу добавить более одной кнопки в Android.Перетаскивание не работает, а также не работает ручное кодирование XML.Пожалуйста, помогите

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/chco"
    tools:context="com.example.tset.test.Prerequisites">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

    </LinearLayout>
</ScrollView>

enter image description here

Ответы [ 4 ]

0 голосов
/ 12 июня 2018

Попробуйте это

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center_vertical"
    android:background="@drawable/login_bg"
    tools:context=".activities.LoginActivity">
    <LinearLayout
        android:orientation="vertical"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/submit"
            android:textSize="18sp"
            android:text="Login"/> 
            <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/submit1"
            android:textSize="18sp"
            android:text="Login1"/> 
    </LinearLayout>

</ScrollView>
0 голосов
/ 12 июня 2018
<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/chco"
            tools:context="com.example.tset.test.Prerequisites">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />

                <Button
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />


            </LinearLayout>
        </ScrollView>
0 голосов
/ 12 июня 2018

Попробуйте это:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/chco"
tools:context="com.example.tset.test.Prerequisites"
android:fillViewport="true">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">


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

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

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

0 голосов
/ 12 июня 2018

Попробуйте это

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/chco"
    tools:context="com.example.tset.test.Prerequisites">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:orientation="horizontal"
                    android:layout_height="wrap_content">

                    <Button
                        android:id="@+id/btnLogin"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Traveler Login" />

                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right"
                        android:text="Login" />
                </LinearLayout>

</ScrollView>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...