如何阻止文本框在Android中滚动

时间:2014-04-27 02:22:01

标签: java xml listview scrollview relativelayout

我正在尝试创建一个带有图像和列表视图的视图,其中线性布局具有垂直方向和EditText,它应始终位于顶部。我应该可以一起滚动图像和列表视图,但不能滚动底部的EditText。

我对android很新,如果我没有任何意义,对不起。问我需要什么更多信息。

这是我的代码..

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="#CDBCDE">

            <FrameLayout
                android:id="@+id/post_container"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">

                <ImageView
                    android:id="@+id/post_profilePictureView1"
                    android:layout_width="75dp"
                    android:layout_height="75dp"
                    android:layout_marginLeft="10dp"
                    android:layout_marginTop="10dp"
                    android:maxHeight="75dp"
                    android:maxWidth="75dp"
                    android:padding="5dp"
                    android:src="@drawable/ic_launcher_web"/>

                <LinearLayout
                    android:layout_width="200dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="85dp"
                    android:layout_marginTop="15dp"
                    android:weightSum="1">

                    <TextView
                        android:id="@+id/post_nameView1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:lines="1"
                        android:maxLength="20"
                        android:maxLines="1"
                        android:singleLine="true"
                        android:text="Name"
                        android:textSize="14dp"
                        android:textStyle="bold" />
                </LinearLayout>

            </FrameLayout>

            <ListView
                android:id="@+id/commentsListView"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@id/post_container"
                android:layout_marginLeft="6dp"
                android:layout_marginRight="6dp"
                android:layout_marginBottom="8dp"
                android:background="#CCBBAA"/>

        </LinearLayout>
    </ScrollView>
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#EDf3F4"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:focusable="true"
        android:focusableInTouchMode="true">
        <EditText
            android:id="@+id/newCommentTextView"
            android:layout_width="315dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:nextFocusUp="@id/newCommentTextView"
            android:hint="Write your comment..."
            android:textSize="20dp"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:fontFamily="sans-serif-light"
            android:background="#FFFFFF">
            </EditText>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="35dp"
            android:layout_toRightOf="@id/newCommentTextView"
            android:id="@+id/newCommentPostButton"
            android:text="comment"
            android:padding="3dp"
            android:layout_alignParentRight="true"/>
        </RelativeLayout>
</RelativeLayout>

,java代码是

package com.example.soquestion;

import java.util.ArrayList;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.os.Build;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getActionBar().hide();
        ListView listview = (ListView) findViewById(R.id.commentsListView);
        String[] values = {"January","February","March","April","May","June","July","August","September","October",
                "November","December"};
        ArrayList<String> arrayList = new ArrayList<String>();
         for (int i = 0; i < values.length; ++i) {
             arrayList.add(values[i]);
            }
         final ArrayAdapter adapter = new ArrayAdapter(this,
                    android.R.layout.simple_list_item_1, arrayList);
                listview.setAdapter(adapter);

    }
}

0 个答案:

没有答案