【问题标题】:ImageView showing under app title and not below itImageView 显示在应用标题下方而不是下方
【发布时间】:2016-05-23 16:18:54
【问题描述】:

我在我的 android 应用中添加了一个 ImageView。半图像显示在应用程序标题栏(显示应用程序名称的栏)下方,而不是显示在应用程序标题栏下方。这是我的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".TopLevelActivity">


    <ImageView
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:src="@drawable/logo"
        android:contentDescription="@string/logo" />

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list_options"
        android:entries="@array/options"/>

【问题讨论】:

    标签: android layout imageview


    【解决方案1】:

    将 android:fitsSystemWindows="true" 添加到您的 LinearLayout

    【讨论】:

      【解决方案2】:

      添加 android:paddingTop 到 imageview 希望对你有帮助

      【讨论】:

      • 我已经这样做了,但这只是一种解决方法,我需要适当的修复。
      【解决方案3】:

      我建议您将 Manifest 中定义的主题设置为:

      android:theme="@style/Theme.AppCompat.NoActionBar"
      

      然后将此代码添加到您的 xml 中

      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#FAFAFA">
      
      <android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="?attr/colorPrimary"
          app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
          app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
          >
      
          <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/title"
              android:text="Your App Title"
              android:textSize="25dp"
              android:textColor="#ffffff"
              />
      
      </android.support.v7.widget.Toolbar>
      
      <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_below="@+id/toolbar"
          android:orientation="vertical"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true">
      
          <ImageView
              android:layout_width="200dp"
              android:layout_height="100dp"
              android:src="@drawable/logo" />
      
          <ListView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/list_options"
              android:entries="@array/options"
              />
      
      </LinearLayout>
      

      View post on imgur.com

      【讨论】:

      猜你喜欢
      • 2017-12-08
      • 2013-03-12
      • 1970-01-01
      • 1970-01-01
      • 2012-11-19
      • 2017-07-27
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      相关资源
      最近更新 更多