Как сделать веб-просмотр и три кнопки? Достаточно ли одного XML-макета? - PullRequest
0 голосов
/ 25 июня 2018

Как сделать веб-просмотр и три кнопки в Android, три кнопки вниз и рядом друг с другом, и веб-вид появляется на оставшемся экране.

Я попробовал следующий код

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="fill_parent" tools:context=".MainActivity"
    android:orientation="vertical"
    >
    <WebView
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:id="@+id/webview"
android:background="#fff"
        />
   <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="100dp"
       android:orientation="horizontal"
       >
       <Button
           android:id="@+id/button1"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_weight="1"
           android:text="Button" />

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

   </LinearLayout>
</LinearLayout>

Ответы [ 2 ]

0 голосов
/ 25 июня 2018
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" tools:context=".MainActivity"
    android:orientation="vertical"
    android:weightSum="5"
    >
    <WebView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:id="@+id/webview"
        android:background="#fff"
        android:layout_weight="4"
        />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="horizontal"
        android:weightSum="3"
        android:layout_weight="1"
        >
        <Button
            android:id="@+id/button1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:id="@+id/button"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

        <Button
            android:id="@+id/button3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />

    </LinearLayout>
</LinearLayout>

Это сделает вашу работу

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

Создать макет в этой схеме

<Relative Layout>
     <LinearLayout 
           weight_sum =3 
           align_parent_bottom>
            <Button_1 
                 weight =1/>
            <Button_2 
                  weight =1/>
            <Button_3 
                  weight =1/>
      </Linear Layout>
     <WebView 
          above linearLayout 
          align_parent_top />
</Relative Layout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...