android - 如何删除Linearlayout中按钮的空白
问题描述
当我将按钮放在线性布局中时,按钮周围有空白区域。删不掉,怎么删?有一张图片。正如您在按钮左侧看到的那样,有很大的空白区域。我不想使用相对布局,因为我需要我的 webview 显示一半的屏幕大小
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>
解决方案
这在线性布局中是不可能的,因此我将其展平为相对布局,请查看:
<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>
另外,我没有为您的 webview 分配固定高度,而不是给予重量。通过这样做,您还可以android:layout_above="@+id/progressBar"
从 listview 中删除,以提供类似重叠效果的 webview,但它符合您的要求。
推荐阅读
- python - 在 Python 3.8 上安装 Matplotlib 时出错
- swift - Xcode 10,Anyobject 类型的值没有成员
- microsoft-graph-api - OneNote API:从 Section 中获取 Pages 列表,过滤掉已删除的页面
- javascript - 如何在 Angular 8 组件中使用 jquery this 关键字
- c - 一次将一个字符复制到其输出的程序
- snowflake-cloud-data-platform - 面临将数据从 SQL Server 表传输到雪花的问题
- c# - 无法加载 Microsoft.Extensions.DependencyInjection.Abstractions
- javascript - 如果任何一个字段为空或未使用 javascript 正确填写,则不应提交表单
- scala - 在 Scala 项目中使用 Maven 运行集成测试和单元测试
- python - 使用布尔条件在 pandas df 中添加列