【问题标题】:Resize ImageView to height of a TextView将 ImageView 的大小调整为 TextView 的高度
【发布时间】:2013-03-24 19:29:47
【问题描述】:

我的 LinearLayout 包含 2 个 TextView(TextView1 和 TextView2)和一个 ImageView。现在我希望 LinearLayout 始终有一个固定的高度,即 ThextView1 的高度,以便 ImageView 使用 fill_parent 调整其 Image 的大小始终为 TextView1 的高度。

 _____________________________________
|TextView1------------------ ImageView|
|TextView1 --- TextView2 --- ImageView|
|TextView1 ----------------- ImageView|

有点难以解释... ImageView 始终应具有 TextView1 的高度并调整其图像大小(同时保持原始纵横比)。

这可能只使用 layout-xml,还是我需要以编程方式进行?

我希望你能帮助我:)

【问题讨论】:

    标签: android android-layout android-imageview textview


    【解决方案1】:
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
    
        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            ... />
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ... />
    
    </LinearLayout>
    

    我没有测试过这个。你指的是这个吗?

    【讨论】:

      猜你喜欢
      • 2013-05-08
      • 2022-01-22
      • 2013-06-27
      • 1970-01-01
      • 1970-01-01
      • 2017-07-15
      • 2013-10-09
      • 1970-01-01
      相关资源
      最近更新 更多