【发布时间】:2015-03-22 15:22:35
【问题描述】:
我遇到了一些 xml 代码,希望您能帮帮我。
所以这就是我需要的/我现在所做的。
我有 3 张 650 像素宽的图像,我需要它们一个在另一个之下,同时保持纵横比。
我用下面的代码做到了,它看起来应该是这样。这里没问题。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ll"
android:orientation="vertical"
android:background="#3afa3f"
android:weightSum="3">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/krk_history"
android:layout_weight="1"
android:background="@drawable/povjestkrka_vintage_yellow600" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/krk_frankopan"
android:background="@drawable/frankopan2_vintage_sundown600" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/krk_turizam"
android:background="@drawable/krk_turizam_vintage"/>
问题是。我需要在每个图像的左下角放置三个文本视图。想象一下它就像图像菜单,每张图像都有文字描述。
所以,我不能使用相对布局或框架布局,因为图像不能很好地相互配合:) 纵横比等之间总是存在差距。我需要 weightsum。
其次,我无法在 Photoshop 中对每张图片上的文本进行硬编码,因为该应用将被翻译,并且需要针对每种语言更改文本。
我可以为每种语言提供不同的图像,但我试图避免这种情况。
啊,是的,还有最后一件事。 我试图将整个线性布局放在相对布局中并将文本放在两者之间,但文本出现在图像下方,我无法将其放在前面。
有什么建议吗?
非常感谢, Xsonz
【问题讨论】:
-
首先使用 ImageView 和 TextViews 构建一个 RelativeLayout/FrameLayout,然后在您的 LinearLayout(而不是 ImageView)中包含这样的布局 ...
<Linear><RelativOrFrame><Image/><Text/><Text/></RelativOrFrame><RelativOrFrame><Image/><Text/><Text/></RelativOrFrame><RelativOrFrame><Image/><Text/><Text/></RelativOrFrame></Linear>或 imagewithtext.xml :<RelativOrFrame><Image/><Text/><Text/></RelativOrFrame>然后<Linear><include layout="layout/imagewithtext" /><include layout="layout/imagewithtext" /><include layout="layout/imagewithtext" /></Linear> -
是什么阻止您以编程方式直接在应用程序中绘制图像中的文本?使用
Canvas和Paintstackoverflow.com/questions/23185453/drawtext-on-imageview
标签: android css image android-layout