【发布时间】:2017-06-24 14:34:26
【问题描述】:
我不知道为什么它在 IDE 中工作,但是当我在我的设备上安装 apk 时。 (我在 RelativeLayout 中有一个 4000x1080 像素的背景图像)。
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#f7f7f7"
android:fillViewport="true"
android:orientation="vertical">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@mipmap/space1"
android:fillViewport="true"
android:padding="0dp">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="56dp"
android:text="Hello World !"
android:textColor="#FFFFFF"/>
<ImageButton
android:id="@+id/imageButton"
android:layout_width="55dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="@null"
android:padding="5dp"
android:scaleType="centerInside"
app:srcCompat="@drawable/level1"
android:gravity="center"
android:layout_marginLeft="455px"
android:layout_marginTop="1300px"/>
</RelativeLayout>
提前感谢您的帮助。
【问题讨论】:
-
我认为问题在于我的布局包含在另一个布局中,因此 onClickListener 无法捕获 ImageView 的 id...实际上是这种情况:父级包含包含 myLayout 和 ImageView 的 child1。 .
-
我在java类中试过这个,但是id不起作用:ImageButton level1 = (ImageButton) findViewById(R.id.father).findViewById(R.id.child).findViewById(R .id.imageView) ;我能做什么?
标签: android xml scrollview