如何伸展图像中的布局行的高度? [英] How to stretch image to row height in layout?

查看:92
本文介绍了如何伸展图像中的布局行的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一行中有是文本视图和形象。我需要伸展图像比例是相同的高度为文本图。那怎么办?

这是布局:

 <?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:ID =@ + ID / RelativeLayout1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=横向><的TextView
    机器人:ID =@ + ID / textView1
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentLeft =真
    机器人:layout_centerVertical =真
    机器人:layout_toLeftOf =@ + ID / imageView1
    机器人:文字=中文字
    机器人:textAppearance =机器人:ATTR / textAppearanceMedium/>< ImageView的
    机器人:ID =@ + ID / imageView1
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentRight =真
    机器人:layout_centerVertical =真
    机器人:adjustViewBounds =真
    机器人:cropToPadding =真
    机器人:SRC =@绘制/ ic_launcher/>
< / RelativeLayout的>


解决方案

只需使用 layout_alignTop layout_alignBottom 对齐从热门你的看法有相同的高度

There're text view and image in one row. I need to stretch image proportionally to be the same height as text view. How to do that?

That's layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:layout_toLeftOf="@+id/imageView1"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:adjustViewBounds="true"
    android:cropToPadding="true"
    android:src="@drawable/ic_launcher" />
</RelativeLayout>

解决方案

just use layout_alignTop and layout_alignBottom to align your views from Top and Bottom to have the same Height

这篇关于如何伸展图像中的布局行的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆