我正在创建一个工具栏。我已经准备好了一切,但我无法摆脱两侧和顶部出现的间隙。它似乎在模仿它下面的列表视图的间隙。我知道我可以删除相对布局中的填充属性。问题是,当我这样做时,列表视图的布局(位于工具栏底部)随之改变,我希望它保持原样。有没有人有关于如何在保持其余活动布局的同时摆脱那些不需要的间隙的建议?
这是我的 xml 布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.jesse.myapp.FavoriteActivity">
<include
layout="@layout/favoritebar"
android:id="@+id/fb"/>
<ListView
android:id="@+id/languageselector"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:clickable="false" />
<TextView
android:id="@+id/checkboxtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/emptyElement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="NO FAVORITES AVAILABLE"
android:textColor="#525252"
android:textSize="19.0sp"
android:visibility="gone" />
<Button
android:id="@+id/checklist"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@mipmap/arrow2"
android:gravity="end"
android:text=""/>
</RelativeLayout>
和工具栏的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:theme= "@style/Toolbarstyle">
</android.support.v7.widget.Toolbar>
如果您想要相对布局内容,这应该可以工作:
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<include
layout="@layout/favoritebar"
android:id="@+id/fb"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.jesse.myapp.FavoriteActivity">
<ListView
android:id="@+id/languageselector"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:clickable="false" />
<TextView
android:id="@+id/checkboxtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/emptyElement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="NO FAVORITES AVAILABLE"
android:textColor="#525252"
android:textSize="19.0sp"
android:visibility="gone" />
<Button
android:id="@+id/checklist"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@mipmap/arrow2"
android:gravity="end"
android:text=""/>
</RelativeLayout>
</LinearLayout>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句