繁体   English   中英

放大后不显示带有imageviews的线性布局

[英]Linear Layout with imageviews doesn't appear after inflating

我有一个线性布局,希望在活动中显示。 这是我用来执行此操作的代码:

final LayoutInflater factory = getLayoutInflater();
final View ps = factory.inflate(R.layout.photo_shooting, null);
final RelativeLayout photoshooting = (RelativeLayout) ps;

//other code...

rscroll.addView(photoshooting, lp);

和布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/photoshooting"
android:background="@drawable/dropdownborder">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:id="@+id/selectedphoto" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/camera_and_film">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:id="@+id/camera"
        android:background="@mipmap/camera" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:id="@+id/cameraroll"
        android:background="@mipmap/cameraroll" />
</RelativeLayout>

问题是,当我将其添加到相对布局rscroll中时,它没有出现。 为什么跑步时看不到它?

可能是因为您的RelativeLayout的ID为“ @ + id / photoshooting”,但您正在向代码中添加“ R.layout.photo_shooting”。

我的问题是我没有按照Blackbelt所述正确布局。 它应该是:

LinearLayout photoshooting = (LinearLayout) ps;

暂无
暂无

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

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