【发布时间】:2017-01-16 03:21:49
【问题描述】:
我的布局底部有 4 个按钮,我希望它们的位置比现在高一点。
我更改了大小和边距等,但这似乎不起作用。它们被放置得更高,而不仅仅是小块。
就像我展示的图片一样,在左侧,屏幕底部的按钮放置正确,在右侧,它们太低了。我需要更改什么代码来解决这个问题,并让它们变得相同?
Klik hier om de afbeelding te bekijken
这是左图中的xml代码,按钮放置正确:
<LinearLayout 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:baselineAligned="false"
android:measureWithLargestChild="false"
android:orientation="vertical"
tools:context="com.example.rodekruis.Contact" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:src="@drawable/rkz_logo"
android:layout_gravity="left"
android:layout_marginLeft="1dp"/>
<ImageView
android:id="@+id/imageButton1"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginRight="40dp"
android:layout_marginTop="10dp"
android:layout_gravity="right"
android:src="@drawable/informatiebutton" />
</FrameLayout>
<ScrollView
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="364dp" >
<TextView
android:id="@+id/textView"
android:layout_width="244dp"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
android:layout_gravity="center"
android:text="@string/title_activity_contact"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black"
android:autoLink="web" />
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="15dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<Button
android:id="@+id/button11"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="Facebook" />
<Button
android:id="@+id/button12"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="Youtube" />
<Button
android:id="@+id/button13"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignLeft="@+id/button5"
android:layout_below="@+id/button8"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="Twitter" />
<Button
android:id="@+id/button14"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignLeft="@+id/button5"
android:layout_below="@+id/button8"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="LinkedIn" />
</LinearLayout>
</LinearLayout>
这是正确的页面,bezoekpage,按钮太低了:
<LinearLayout 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:orientation="vertical"
tools:context="com.example.rodekruis.Bezoek">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.rodekruis.MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:src="@drawable/rkz_logo"
android:layout_gravity="left"
android:layout_marginLeft="1dp"/>
<ImageView
android:id="@+id/imageButton1"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_marginBottom="20dp"
android:layout_marginRight="40dp"
android:layout_marginTop="10dp"
android:layout_gravity="right"
android:src="@drawable/informatiebutton" />
</FrameLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="244dp"
android:layout_height="280dp"
android:layout_gravity="center"
android:text="@string/title_activity_bezoek"
android:layout_marginTop="30dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
<TextView
android:id="@+id/textView2"
android:layout_width="244dp"
android:layout_height="95dp"
android:layout_gravity="center"
android:text="Klik hier voor de uitgebreide bezoektijden."
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="80dp"
android:orientation="horizontal">
<Button
android:id="@+id/button11"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="Facebook" />
<Button
android:id="@+id/button12"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="Youtube" />
<Button
android:id="@+id/button13"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignLeft="@+id/button5"
android:layout_below="@+id/button8"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="Twitter" />
<Button
android:id="@+id/button14"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignLeft="@+id/button5"
android:layout_below="@+id/button8"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="LinkedIn" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
你真正想要什么?添加具有所需结果的图像?
-
我复制了你的第二个布局文件并检查了它,按钮的位置完全符合你的要求。
-
Sohail Zahid,当您点击图片时,您会看到 2 个屏幕。左边的,底部有 4 个按钮,离屏幕的整个底部只有一点点。右边的按钮具有相同的按钮,但它们位于屏幕下方。我希望它们的高度相同。
标签: java android eclipse button