Fra*_*cia 5 android gridview padding
我试图将我的列之间的间隔减小GridView到0,以使布局100%填充我的项目。此刻,我仍然在项目的顶部和项目之间有一些填充。左右两侧看起来像我想要的。
这是我的片段布局的代码:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/movies_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<GridView
android:id="@+id/moviesGrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="@dimen/poster_width"
android:numColumns="auto_fit"
android:verticalSpacing="0dp"
android:stretchMode="columnWidth"
android:textAlignment="center" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
这是Activity_main布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#E8F5E9"
android:fitsSystemWindows="false"
app:itemTextColor="@android:color/secondary_text_light"
app:menu="@menu/settings_header">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
最后,这是我的dimens.xml文件:
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="poster_width">180dp</dimen>
<dimen name="poster_height">280dp</dimen>
</resources>
Run Code Online (Sandbox Code Playgroud)
现在是这样的:
我尝试使用
android:stretchMode =“ NONE”
或只是将0写入每个填充atribbute,但这没有用。希望有人能够帮助我。
我还检查了这篇文章,以了解我现在所拥有的内容,然后在每个项目之间进行非常大的填充: Android:减少GridView中列之间的空间
谢谢大家!
| 归档时间: |
|
| 查看次数: |
993 次 |
| 最近记录: |