【发布时间】:2017-08-21 19:16:01
【问题描述】:
我有一个框架布局,里面有一个 ImageView 和一个 TextView。我打算在图片的中心制作那个文字。 问题是图像不适合,ImageView 不会很好地包裹内容的高度。看图片:
我尝试混合高度和 with(包装内容并匹配父级),但图片仍然不太适合。 这是xml:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:srcCompat="@drawable/tvrdjava"
android:id="@+id/imageView3" />
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/textView6"
android:textAlignment="center"
android:textColor="@android:color/white"
/>
</FrameLayout>
图片位于不同的可绘制文件夹中,用于不同的分辨率(hdpi、mdpi、xhdpi、xxhdpi、xxxhdpi)。
【问题讨论】:
-
为什么不对 ImageView 和 TextView 使用 RelativeLayout?
-
你可以使用 android:background="@drawable/your_image ..
-
因为我不能把文字放在图片上。 @MatPag
-
android:background= ... 出于某种原因拉伸图像。 @RavindraKushwaha
标签: android android-layout android-framelayout