白色边框取决于图像的大小

时间:2017-01-18 09:49:31

标签: android imageview android-linearlayout relativelayout

我想制作一个具有白色边框的specyfic高度(屏幕的1/3)的ImageView,并且图像将根据高度调整大小(以保持比例)。如果我能够在图像下方添加TextView,那将是完美的。我想得到那样的smth:

enter image description here

  <LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:background="@color/backgroundContent">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:gravity="center"
   >
    <ImageView
        android:contentDescription="@string/pic"
        android:id="@+id/pic"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"
        android:padding="5dp"/>
    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progressPic"
        android:layout_centerInParent="true"
        android:visibility="gone"/>

</RelativeLayout>

编辑:我是使用Glide库下载图片的网址

0 个答案:

没有答案
相关问题