繁体   English   中英

工具栏顶部的空白区域。 Android、Java

[英]Empty space on top of toolbar. Android, Java

我刚刚在我的应用程序中包含了一个选项菜单,但在我的一项活动中,它似乎创建了一个白色的空白区域 - 谁能告诉我为什么? 它适用于同一应用程序中的其他活动,但不适用于此单个活动。 我希望任何人都可以提供帮助:-)

public class GifsActivity extends OptionsMenu {

    private Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gifs);
        toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        ImageView gifImageView = (ImageView) findViewById(R.id.iv_gif);

        Glide.with(this)
                .load("http://i.imgur.com/Vth6CBz.gif")
                .asBitmap()
                .placeholder(R.drawable.ic_cloud_off_red)
                .error(R.drawable.ic_cloud_off_red)
                .into(gifImageView);
    }

}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:gravity="center_vertical"
    android:orientation="vertical"
    tools:context="com.example.examand1.GifsActivity">

    <include layout="@layout/toolbar_layout"
        />

    <ImageView
        android:id="@+id/iv_gif"
        android:layout_width="match_parent"
        android:layout_height="220dp" />

</RelativeLayout>

活动图片

从布局中删除android:gravity="center_vertical" 然后您的布局将如下所示:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include 
        android:id="@+id/include"
        layout="@layout/toolbar_layout"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"/>

    <ImageView
        android:layout_below="@id/include"
        android:id="@+id/iv_gif"
        android:layout_width="match_parent"
        android:layout_height="220dp" />

</RelativeLayout>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM