【发布时间】:2013-11-30 18:46:18
【问题描述】:
XML文件的结构是:
FrameLayout
ImageView
LinearLayout
TextView
TextView
当我为 LinearLayout 使用背景颜色时,ImageView 的可绘制对象不会出现。如果我从 LinearLayout 可绘制对象中删除 bg 颜色就在它的位置。
我正在这样的代码中添加可绘制对象:
if( placetype == 0 ) {
ImageView im0 = (ImageView) myContentsView.findViewById(R.id.infowindow_imageview);
int imageResource0 = R.drawable.beer_white;
im0.setImageResource(imageResource0);
} else if( placetype == 1 ) {
//etc ...
还有 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content" android:orientation="vertical" >
<FrameLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:foreground="?activatableItemBackground"
android:id="@+id/map_info_top" >
<ImageView
android:id="@+id/infowindow_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_marginRight="-12dp"
android:layout_marginTop="-12dp"
android:adjustViewBounds="true"
android:alpha="0.3"
android:contentDescription="@null"
android:scaleType="fitXY" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/red_drink"
android:orientation="vertical" >
<TextView
style="@style/TextHeader"
android:id="@+id/custom_infowindow_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingBottom="8dp" />
<TextView
style="@style/TextHeaderSub"
android:text="Click to Read more"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingBottom="8dp"
/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
由于 ImageView 和 LinearLayout 在 FrameLayout 中,我不认为重叠视图会有问题。 有人可以解释一下我在这里做错了什么吗?
【问题讨论】:
标签: android xml android-layout