EditText不完全高于软键盘

时间:2015-10-30 05:47:30

标签: android android-layout android-fragments android-activity

所以我一直在研究如何让这个工作2小时: 我需要:SwiperRefreshLayout -> ScrollView -> RelativeLayout -> EditText

如果EditText包含10行,我点击第5行,键盘会调整大小,但只会到第5行。我想要它,以便它为整个EditText调整大小。例如,如果我单击EditText的第一行,我希望显示它的整行10行。

我已经尝试过的事情:
android:windowSoftInputMode="adjustResize"
使用RelativeLayout而不是Linear //

** XML:**

<android.support.v4.widget.SwipeRefreshLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivityFragment"
    android:id="@+id/swipe">

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@color/background">

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Open Saved Location"
                android:id="@+id/savedLocations"
                android:layout_gravity="center"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true" />

            <TextView
                android:text="Estimated Address"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textView2"
                android:layout_below="@+id/savedLocations"
                android:layout_centerHorizontal="true" />

            <TextView
                android:text="Unable to estimate address!"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/getAddress"
                android:gravity="center"
                android:autoText="false"
                android:background="@color/white"
                android:layout_below="@+id/getCords"
                android:layout_centerHorizontal="true" />

            <TextView
                android:text="Unable to find latitude and longitude!"
                android:layout_width="wrap_content"
                android:textAlignment="center"
                android:layout_height="wrap_content"
                android:id="@+id/getCords"
                android:background="@color/white"
                android:layout_below="@+id/textView2"
                android:layout_centerHorizontal="true" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Save Location"
                android:id="@+id/saveLocation"
                android:layout_gravity="center_horizontal"
                android:layout_below="@+id/getAddress"
                android:layout_centerHorizontal="true" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:background="@color/white"
                android:maxLines="9"
                android:text="Unable to create message preview!"
                android:id="@+id/message"
                android:layout_below="@+id/textView"
                android:layout_centerHorizontal="true" />

            <Button
                android:text="Select Contact" android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/selectContact"
                android:layout_gravity="center_horizontal"
                android:layout_below="@+id/message"
                android:layout_centerHorizontal="true"
                android:layout_alignRight="@+id/saveLocation"
                android:layout_alignEnd="@+id/saveLocation" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:text="Message Preview"
                android:id="@+id/textView"
                android:layout_below="@+id/saveLocation"
                android:layout_centerHorizontal="true" />

        </RelativeLayout>
    </ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.whereyouat" >

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.SEND_SMS" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.MyCompatTheme"
            android:windowSoftInputMode="stateHidden|adjustResize" >

        </activity>
        <activity
            android:name=".Contacts"
            android:label="@string/title_activity_contacts"
            android:theme="@style/AppTheme.MyCompatTheme" >
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MainActivity" />
            <meta-data
                android:name="android.app.searchable"
                android:resource="@xml/searchable" >
            </meta-data>
        </activity>
        <activity
            android:name=".TESTING"
            android:label="@string/title_activity_testing"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="stateHidden|adjustResize">
        </activity>

    </application>

</manifest>

1 个答案:

答案 0 :(得分:0)

尝试使用清单文件

<activity
   android:name="com.android.test.LoginActivity"
   android:windowSoftInputMode="stateHidden|adjustResize" >
</activity>
相关问题