我使用以下代码垂直显示了一系列图像按钮。我可以成功滚动浏览所创建的图像,但屏幕中间存在无法修复的空白。我相信该错误源于我使用的LinearLayout,但使用相对或内含的布局进行了切换,但并未改变任何内容。
我的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/homepbckrnd">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageButton
android:id="@+id/imageButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
app:srcCompat="@mipmap/facebook" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="229dp"
app:srcCompat="@drawable/ddrr" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="0dp"
app:srcCompat="@drawable/ic_poll_black_24dp" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="0dp"
app:srcCompat="@mipmap/google" />
<ImageButton
android:id="@+id/imageButton5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ddrr" />
<ImageButton
android:id="@+id/imageButton6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/facebook" />
<ImageButton
android:id="@+id/imageButton7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/facebook" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
删除android:layout_marginTop="229dp"
您imageButton2
通过这样做,你是你的形象,这是造成这个问题为大家讲解应用的229dp上边距。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句