Как убрать пустое пространство кнопки внутри Linearlayout - PullRequest
0 голосов
/ 03 октября 2019

Когда я помещаю кнопку внутрь linearlayout, вокруг кнопки появляется свободное место. Я не могу удалить это, Как удалить это? Есть картинка. как вы видите слева от кнопки есть большое пустое пространство. я не хочу использовать относительный макет, потому что мне нужно мое веб-просмотр, показывающий половину размера экрана

https://i.stack.imgur.com/TJIJ0.jpg

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/linearlayoutweblist"
        android:layout_above="@+id/gettitle"
        android:orientation="vertical">

        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight=".53"
            android:choiceMode="singleChoice"
            android:listSelector="#a2aed3"
            android:layout_above="@+id/progressBar" />

        <Button
            android:layout_width="48dp"
            android:layout_height="wrap_content"
            android:maxHeight="5dp"
            android:minWidth="5dp"
            android:visibility="visible"
            android:background="@drawable/ic_highlight_off_black_24dp"
            android:id="@+id/closebtn"
            android:layout_gravity="right|end"
            android:gravity="right|end" />

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_above="@+id/webviewlay"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:indeterminate="true"
            android:layout_marginTop="-7dp"
            android:layout_marginBottom="-7dp"
            android:visibility="visible"
            style="@style/Widget.AppCompat.ProgressBar.Horizontal"
            />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/webviewlay"
            android:visibility="visible"
            android:paddingTop="1dp"
            android:layout_weight=".47"
            android:paddingBottom="2dp"
            android:background="@drawable/topline"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_above="@+id/gettitle">

            <WebView
                android:id="@+id/arabicfont"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                />

        </LinearLayout>


    </LinearLayout>



Ответы [ 2 ]

1 голос
/ 03 октября 2019

Это невозможно в линейном макете, поэтому я сопоставил это с относительным макетом. Проверьте это:

<RelativeLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/linearlayoutweblist"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">



    <ListView
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:choiceMode="singleChoice"
        android:listSelector="#a2aed3"
        android:layout_above="@+id/progressBar" />


    <Button
        android:layout_width="48dp"
        android:layout_height="wrap_content"
        android:maxHeight="5dp"
        android:minWidth="5dp"
        android:visibility="visible"
        android:background="@drawable/ic_highlight_off_black_24dp"
        android:id="@+id/closebtn"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_above="@id/progressBar"/>

    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_above="@+id/webviewlay"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        android:layout_marginTop="-7dp"
        android:layout_marginBottom="-7dp"
        android:visibility="visible"
        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
        />

       <WebView
            android:id="@+id/webviewlay"
            android:paddingTop="1dp"
            android:paddingBottom="2dp"
            android:layout_alignParentBottom="true"
            android:layout_width="match_parent"
            android:layout_height="400dp"
            />
</RelativeLayout>

Кроме того, вместо того, чтобы придать вес, я назначил фиксированный рост вашему веб-представлению. Сделав это, вы также можете удалить android:layout_above="@+id/progressBar" из списка, чтобы придать веб-виду эффект перекрытия, но он соответствует вашим требованиям.

0 голосов
/ 03 октября 2019

Вы можете сделать это, обернув ListView и Button FramLayout:

<LinearLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/linearlayoutweblist"
    android:layout_above="@+id/gettitle"
    android:orientation="vertical">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight=".53">

        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:choiceMode="singleChoice"
            android:listSelector="#a2aed3"
            android:layout_above="@+id/progressBar" />

        <Button
            android:layout_width="48dp"
            android:layout_height="wrap_content"
            android:maxHeight="5dp"
            android:minWidth="5dp"
            android:visibility="visible"
            android:background="@drawable/ic_highlight_off_black_24dp"
            android:id="@+id/closebtn"
            android:layout_gravity="right|end|bottom"
            android:gravity="right|end" />
    </FrameLayout>



    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_above="@+id/webviewlay"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        android:layout_marginTop="-7dp"
        android:layout_marginBottom="-7dp"
        android:visibility="visible"
        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webviewlay"
        android:visibility="visible"
        android:paddingTop="1dp"
        android:layout_weight=".47"
        android:paddingBottom="2dp"
        android:background="@drawable/topline"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_above="@+id/gettitle">

        <WebView
            android:id="@+id/arabicfont"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />

    </LinearLayout>


</LinearLayout>

Вам нужно будет переместить android:layout_weight=".53" с ListView на FrameLayout и добавитьbottom до Button's android:layout_gravity

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