android - 在android中设置 ImageView 的高度

标签 android android-framelayout

我想在包含 2 个 TextView 的线性布局中添加背景图像。我是使用框架布局来实现的。但是图像没有根据线性布局的大小进行缩放。任何人都可以帮忙吗?以下是我的布局文件

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/FrameLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/button_update_normal" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

    </LinearLayout>

</FrameLayout>

最佳答案

您可以通过以下方式设置线性布局的背景

android:background="imagename"

关于android - 在android中设置 ImageView 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19070864/

相关文章:

android - Androidmanifest.xml文件中的gradle构建错误

android - 如何检查 Jetpack Compose 中列表项的可见性

android - 是否可以将 onTouchEvent 传递给 Android 中的多个 View ?

android - 为什么 setVisibility 不适用于 Fragment/FrameLayout

android - Android Support4Demos 的 FragmentTabs 示例中的两个框架布局

android:如何将填充添加到 FrameLayout 内的 LinearLayout

android - 如何设置按钮的xml布局

java - 如何从指纹扫描仪获取输入并保存

android - Android 的 c++11 多线程问题,其中某些线程未正确安排

android - 如何增加 LVL 缓存有效时间?