edittext在按钮上方

时间:2012-12-05 14:03:38

标签: android

enter image description here我尝试过很多次,但没有...我在屏幕上有一个图像,一个editext和两个按钮。填充edittext,在按钮上方,用户无法点击“发送”或“取消”。我也尝试使用“scrollview”,但我遇到了同样的问题。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/inviabackground2"
android:orientation="vertical"
android:layout_weight="1"
tools:context=".MainActivity" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/logoinvia" />

<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="wrap_content"
    android:orientation="horizontal" >

</LinearLayout>

            <EditText
                android:id="@+id/editText1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10" >

</EditText>

<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="wrap_content"
    android:gravity="bottom"
    android:layout_weight="1"
    android:orientation="horizontal" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Invia per mail!" />

            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center_vertical|center_horizontal"
                android:text="Annulla" />

</LinearLayout>
</LinearLayout>

3 个答案:

答案 0 :(得分:1)

这对我有用。它会在用户输入时向下滚动。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="bottom"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:layout_alignParentTop="true"
            android:src="@drawable/ic_launcher" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/imageView1"
            android:ems="10" >
        </EditText>

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/editText1"
            android:layout_alignParentLeft="true"
            android:text="Invia per mail!" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/editText1"
            android:layout_toRightOf="@id/button1"
            android:layout_alignParentRight="true"
            android:text="Annulla" />
    </RelativeLayout>

</ScrollView>

答案 1 :(得分:0)

这是布局:

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:weightSum="1" xmlns:android="http://schemas.android.com/apk/res/android">


<ScrollView 
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:layout_weight="0.30"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="bottom"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:layout_alignParentTop="true"
            android:src="@drawable/ic_launcher" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/imageView1"
            android:ems="10" >
        </EditText>


    </LinearLayout>

</ScrollView>

<LinearLayout 
    android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="0.70"
            android:gravity="center"
            android:weightSum="1">

    <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/editText1"
            android:layout_alignParentLeft="true"
            android:text=" mail!" 
            android:layout_weight="0.50"/>

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/editText1"
            android:layout_toRightOf="@id/button1"
            android:layout_alignParentRight="true"
            android:text="xyz" 
            android:layout_weight="0.50"/>

</LinearLayout>

</LinearLayout>

答案 2 :(得分:0)

这是你的解决方案:

![<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:weightSum="1" xmlns:android="http://schemas.android.com/apk/res/android">

     <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:layout_alignParentTop="true"
            android:src="@drawable/ic_launcher" />


<ScrollView 
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:layout_weight="0.50"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="bottom"
        android:orientation="vertical" >



        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/imageView1"
            android:ems="10" >
        </EditText>


    </LinearLayout>

</ScrollView>

<LinearLayout 
    android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="0.50"
            android:gravity="center"
            android:weightSum="1">

    <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/editText1"
            android:layout_alignParentLeft="true"
            android:text=" mail!" 
            android:layout_weight="0.50"/>

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/editText1"
            android:layout_toRightOf="@id/button1"
            android:layout_alignParentRight="true"
            android:text="xyz" 
            android:layout_weight="0.50"/>

</LinearLayout>

</LinearLayout>

enter image description here

相关问题