Android 布局 - 不显示 ImageView

标签 android android-layout layout android-framelayout

这是我的布局:

<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">

      <SurfaceView android:id="@+id/preview_view"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_centerInParent="true"/>

      <ViewfinderView
            android:id="@+id/viewfinder_view"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@color/transparent"/>

      <LinearLayout 
            android:id="@+id/result_view"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@color/result_view"
            android:visibility="gone"
            android:padding="4dip">

     </LinearLayout>
     <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <ImageView android:id="@+id/App_logo"
                  android:src="@drawable/mylogo"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_weight="1" />

            <TextView android:id="@+id/status_view"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="bottom|center_horizontal"
                  android:background="@color/transparent"
                  android:text="@string/msg_default_status"
                  android:textColor="@color/status_text"
                  android:textSize="14sp"/>

      </LinearLayout>
</FrameLayout>

问题是 XML 底部的 ImageView 没有显示。 有什么想法吗?

10 倍 :)

最佳答案

您的每个 View 都包含“fill_parent”的布局宽度和高度属性。您需要为它们指定“wrap_content”,或者将它们放在具有正负边距的容器中,否则它们都会尝试占用所有可用空间。

关于Android 布局 - 不显示 ImageView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6311696/

相关文章:

android - 调试端口 (8700) 正忙,请确保没有其他 Activity 的调试连接到同一应用程序?

android - 将 LinearLayout 对齐到底部,在填满屏幕的 ViewPager 下

java - 如何将光标(android)放入二维数组?

android - 在 ConstraintLayout 之外定位 View

android - viewpager 中的 ViewFlipper

android - 禁用时将 editText 的内容椭圆化

html - 如何修复此布局

android - Listview改变键盘打开其他 View 的位置

java - 我怎样才能为我的结构获得无限数量的项目

android - 设置 ADT Eclipse