![](/img/trans.png)
[英]Reduce or no gap between a LinearLayout and a ListView in Android
[英]Gap between last button an LinearLayout
我的問題是,在布局中,我的視圖的最后一個元素(按鈕)與視圖的“底部”之間有很大的差距。 我在ScrollView
使用LinearLayout
。 我的錯在哪里? 我嘗試將所有填充都設置為0dp,但是仍然存在相同的問題。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
tools:context=".MainMenu">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/bg_ohne"
>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="126dp"
android:paddingTop="5dp"
android:layout_gravity="center"
android:contentDescription="seas"
android:src="@drawable/logo" />
<Button
android:id="@+id/btLineup"
android:layout_marginTop="60dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/lineup"
/>
<Button
android:id="@+id/btZumSpiel"
android:paddingTop="10dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/wegweiserzumspiel"/>
<Button
android:id="@+id/btHighscore"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="0dp"
android:layout_marginBottom="0dp"
android:layout_height="wrap_content"
android:background="@drawable/highscore" />
</LinearLayout>
</ScrollView>
用最后一個按鈕替換此代碼,並注意以下行android:layout_marginTop =“ 40dp”,現在您可以增加或減少該值。
<Button
android:id="@+id/btHighscore"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="0dp"
android:layout_marginTop="40dp"
android:layout_marginBottom="0dp"
android:layout_height="wrap_content"
android:background="@drawable/btnblue" />
我找到了解決方案:
組
android:background
到ScrollView
標記中就可以了!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.