Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 布局中的较高按钮_Java_Android_Eclipse_Button - Fatal编程技术网

Java 布局中的较高按钮

Java 布局中的较高按钮,java,android,eclipse,button,Java,Android,Eclipse,Button,我在布局的底部有4个按钮,我希望它们的位置比现在稍微高一点 我改变了尺寸和边距,但这似乎不起作用。它们被放置得更高,而不仅仅是一点点 就像我展示的图像一样,在左边,屏幕底部的按钮放置正确,在右边,按钮太低。我需要修改什么代码来解决这个问题,并让它们变得相同 这是左图中正确放置按钮的xml代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://s

我在布局的底部有4个按钮,我希望它们的位置比现在稍微高一点

我改变了尺寸和边距,但这似乎不起作用。它们被放置得更高,而不仅仅是一点点

就像我展示的图像一样,在左边,屏幕底部的按钮放置正确,在右边,按钮太低。我需要修改什么代码来解决这个问题,并让它们变得相同

这是左图中正确放置按钮的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>

首先停止为布局提供固定的高度和宽度,这会给多尺寸设备带来问题。请遵循好的教程或书籍开始学习android

在第一个布局中,将滚动高度固定为364。 在第二个布局中,文本视图和linearlayout的组合高度为280+95=375,包括文本视图边缘P=30dp,则变为405。这就是为什么布局按钮位于底部。
在第二个布局中使用scrollview,高度也为364。这将解决您的问题。

首先停止为布局提供固定的高度和宽度,这会给多尺寸设备带来问题。请遵循良好的教程或书籍开始使用android

在第一个布局中,将滚动高度固定为364。 在第二个布局中,文本视图和linearlayout的组合高度为280+95=375,包括文本视图边缘P=30dp,则变为405。这就是为什么布局按钮位于底部。
在第二个布局中使用高度为364的scrollview。这将解决您的问题。

我更正了您的代码。。如果这个答案有帮助的话,请把它做得正确

<RelativeLayout 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>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="10dp"
    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>


我更正了你的代码。。如果这个答案有帮助的话,请把它做得正确

<RelativeLayout 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>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="10dp"
    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>


你真正想要什么?添加具有所需结果的图像?我复制了您的第二个布局文件并进行了检查,按钮按您希望的方式放置在更高的位置。Sohail Zahid,当您单击图片时,您会看到两个屏幕。左边的按钮上有4个按钮,离整个屏幕底部只有一点距离。右边的按钮相同,但它们位于屏幕下方。我希望他们都一样高。你到底想要什么?添加具有所需结果的图像?我复制了您的第二个布局文件并进行了检查,按钮按您希望的方式放置在更高的位置。Sohail Zahid,当您单击图片时,您会看到两个屏幕。左边的按钮上有4个按钮,离整个屏幕底部只有一点距离。右边的按钮相同,但它们位于屏幕下方。我希望它们的高度相同。